简体   繁体   中英

React Native - Invariant Violation "RNDateTimePicker"

I'm trying to use the React Native DateTimePicker library in my app and I get the following error when I attempt to pick a date:

Invariant Violation: Invariant Violation: requireNativeComponent: "RNDateTimePicker" was not 
found in the UIManager.

Anyone else experiences this error? I have gone through other posts like the following but still can't seem to figure it out. Git repo

I am using expo - which may not be compatible with this library. If not, does anyone else have any other recommendations for a date/time library?


I also tried linking, but to no prevail

You cannot use react-native-dateTimepicker because it requires manual linking of native code. So its not possible with expo. You can use the expo date time picker which is exclusively made for expo : Check this out expo-picker . Hope it helps.

After library install. Do pod install

If you are not on Expo then

Update XCode.

Since version 3.0, RNDateTimePicker requires XCode 11.6 to build.

you need XCode 11.6 to build this version, and you need this version to properly support iOS 14 (for that you need XCode 12)

From: https://github.com/react-native-community/datetimepicker/releases/tag/v3.0.0

******* it occurs in RN > .6 *******

first, run

npm i @react-native-community/datetimepicker: 2.1.0

it works correctly

after, run

npm i @react-native-community/datetimepicker

to get the last version

it works correctly again, without any issue

good luck

通过运行重新构建您的应用程序

npx react-native run-ios

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM