When trying to render the component, it simply does not show, raising the following exception a few seconds later:
[Unhandled promise rejection: TypeError: null is not an object (evaluating '_reactNative.NativeModules.RNTimePickerAndroid.open')]
- node_modules\@react-native-community\datetimepicker\src\timepicker.android.js:39:45 in open$
- node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:45:44 in tryCatch
- node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:271:30 in invoke
- node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:45:44 in tryCatch
- node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:135:28 in invoke
- node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:170:17 in <unknown>
- node_modules\promise\setimmediate\core.js:45:7 in tryCallTwo
- node_modules\promise\setimmediate\core.js:200:23 in doResolve
- node_modules\promise\setimmediate\core.js:66:12 in Promise
- node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:169:27 in callInvokeWithMethodAndArg
- node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:192:38 in enqueue
- node_modules\@babel\runtime\node_modules\regenerator-runtime\runtime.js:216:8 in async
* null:null in open
- node_modules\@react-native-community\datetimepicker\src\datetimepicker.android.js:35:39 in RNDateTimePicker
- node_modules\react-native\Libraries\Renderer\oss\ReactNativeRenderer-dev.js:9473:27 in renderWithHooks
- ... 29 more stack frames from framework internals
Running on expo 3.11.3.
Library version: any
Expected behavior:
For some reason, RNTimePickerAndroid does not seem to be a thing when using expo. Not sure about when doing bare development.
Changing line 39 inside timepicker.android.js from
return NativeModules.RNTimePickerAndroid.open(options);
to
return NativeModules.TimePickerAndroid.open(options);
fixes the issue.
The complete solution should probably include a check to see if it's running on expo.
Seeing the same thing but i'm not using expo.
I fixed this by running:
./node_modules/.bin/react-native link @react-native-community/datetimepicker
Even although it should be auto-linked. (Bare react-native 0.61.5. project) The link command above fails, and running yarn android now gives errors/warnings about manually linked modules, but everything works.
@paulosborne on android, even after running the auto-linking i still had the same error (RN 0.6.1). i was able to get the library working by walking through the manual installation -- and noticed my MainApplication.java file had not properly updated (the previous steps were correct though).
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
...
new RNDateTimePickerPackage()
);
}
hello, the original error is cause by not having the module linked correctly.
As the issue template explains, we require that you provide a runnable example (please try reproducing the bug with our example app) that reproduces the bug in a github repository. Please try to minimize the superfluous code and focus only on reproducing the bug.
Most helpful comment
For some reason,
RNTimePickerAndroiddoes not seem to be a thing when using expo. Not sure about when doing bare development.Changing line 39 inside
timepicker.android.jsfromto
fixes the issue.
The complete solution should probably include a check to see if it's running on expo.