Invalid hook call on RNPickerSelect

1.7k views Asked by At

I am building my first react-native app for both android and IOS. In order for my app to function, I need to use RNPickerSelect. But for some reason when I try to do

<RNPickerSelect 
              onValueChange={(value) => setOrgin(value)}
              value={orgin}
              useNativeAndroidPickerStyle={false}
              items={countries} placeholder={{label: "Country of Orgin", value: null}} style={pickerSelectStyles}
          />

on android I get "Invalid hook call. Hooks can only be called inside of the body of a function component. " How can I solve this issue

3

There are 3 answers

0
Gaben007 On BEST ANSWER

Same issue is here, I have tried with npm i react-native-picker-select --legacy-peer-deps as turkun mentioned and it seems working me too. Node version may have effect for the fix, I have v12.22.12.

0
turkun On

I have re-install the module with this command => npm i react-native-picker-select --legacy-peer-deps

0
Joachim de Bernis On

re-install the module with this command => npm i react-native-picker-select --legacy-peer-deps ... works for me also. Probably a conflict on expo dependencies. It works with Expo but no more when creating de app bundle with eas. This module is no longer supported. I change by using this : https://github.com/ouroboroscoding/react-native-picker