Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard.dismiss is not defined on RN 0.33 #2

Closed
garlab opened this issue Feb 6, 2017 · 3 comments · Fixed by #5
Closed

Keyboard.dismiss is not defined on RN 0.33 #2

garlab opened this issue Feb 6, 2017 · 3 comments · Fixed by #5

Comments

@garlab
Copy link

garlab commented Feb 6, 2017

Hi,

I tried to use done-bar on a project stuck with [email protected] but I got the error _reactNative.Keyboard.dismiss is not a function, because Keyboard.dismiss is not defined on old versions of RN.

This can be easily solved app-side by this polyfill

import { Keyboard } from 'react-native';
import TextInputState from 'TextInputState';

if (!Keyboard.dismiss) {
  Keyboard.dismiss = () => TextInputState.blurTextInput(TextInputState.currentlyFocusedField());
}

Just to let you know in case you want to support previous versions.

@mileung
Copy link
Owner

mileung commented Feb 6, 2017

Thanks! Added this in 1.0.1 which just got published

@mileung mileung closed this as completed Feb 6, 2017
@garlab
Copy link
Author

garlab commented Feb 7, 2017

I tried to update to 1.0.1 and now I got that error:

Unable to resolve module TextInputState from /Users/<project_dir>/node_modules/done-bar/src/DoneBar.js: Unable to find this module in its module map or any of the node_modules directories under /Users/node_modules/TextInputState and its parent directories

I think import TextInputState from 'TextInputState' will only be resolved when the project uses the same version of RN as the lib. However this should work all the time:

import TextInputState from 'react-native/lib/TextInputState';

@mileung
Copy link
Owner

mileung commented Feb 7, 2017

Added this is 1.0.2 =D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants