-
Notifications
You must be signed in to change notification settings - Fork 502
Description
Invalid Hook Call error inside react-native-picker-select node module.
Describe the bug
I get this issue everytime I build in android, it would show "Invalid Hook Call error" when it has to render the screen that uses RNPickerSelect (react-native-picker-select)
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
- You might have mismatching versions of React and the renderer (such as React DOM)
- You might be breaking the Rules of Hooks
- You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
This error is located at:
in PickerAndroid (at Picker.js:174)
in Picker (at src/index.js:491)
in RCTView (at View.js:32)
in View (at src/index.js:489)
in RCTView (at View.js:32)
in View (at createAnimatedComponent.js:211)
in AnimatedComponent (at createAnimatedComponent.js:264)
in AnimatedComponentWrapper (at TouchableOpacity.js:224)
in TouchableOpacity (at TouchableOpacity.js:280)
in TouchableOpacity (at src/index.js:483)
in RNPickerSelect (at Picker.tsx:39)
in RCTView (at View.js:32)
in View (at Picker.tsx:38)
in RCTView (at View.js:32)
in View (at Picker.tsx:36)
To Reproduce
Steps to reproduce the behavior:
- Add react-native-picker-select on a react native app (react-native init Test)
- Add RNPickerSelect useNativeAndroidPickerStyle={false} in a screen with data
- Build in android (react-native run-android)
- See error
Expected behavior
It would render the picker and not crash the app
Screenshots
Additional details
- Device: Android 11G Emulator
- OS: Android 11
- react-native-picker-select version: ^8.0.4
- react-native version: ^0.68.5
- expo sdk version: n/a
Reproduction and/or code sample
<RNPickerSelect
placeholder={{label: 'test', value: 'test'}}
items={items}
onValueChange={props.functionOnChange}
style={styles}
useNativeAndroidPickerStyle={false}
/>

