0

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

Itay Lador
  • 313
  • 1
  • 10
  • seems issue is not there in this code, You have used any of hooks outside of a function body, try to remove that and check. – Kailash Sep 28 '22 at 04:14
  • I checked that but it works fine when the RNPickerSelect is not in the code, but when I add it, it gives me the error. – Itay Lador Sep 28 '22 at 12:18

3 Answers3

1

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

turkun
  • 11
  • 1
1

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.

Gaben007
  • 38
  • 4
1

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

Joachim de Bernis
  • 101
  • 1
  • 2
  • 7