lawnstarter / react-native-picker-select

🔽 A Picker component for React Native which emulates the native <select> interfaces for iOS and Android
https://npmjs.com/package/react-native-picker-select
MIT License
1.73k stars 491 forks source link

Bug in Android #509

Open OmarKhanfer opened 1 year ago

OmarKhanfer commented 1 year ago

Describe the bug
I have the following packages

"@react-native-picker/picker": "^2.4.10",
"react": "18.2.0",
"react-native": "0.69",
"react-native-picker-select": "^8.0.4",

its giving me error "Invalid hook call. Hooks can only be called inside the body of a function component. this could happen for one of the following reasons ..."

<RNPickerSelect
                onValueChange={(value) => console.log(value)}
                items={[
                    { label: 'Football', value: 'football' },
                    { label: 'Baseball', value: 'baseball' },
                    { label: 'Hockey', value: 'hockey' },
                ]}
            />

To Reproduce
Steps to reproduce the behavior:

  1. Run Android version to 'npm run android'
  2. Display Android Emulator
  3. Showing in the main page
  4. See error Screen Shot 2023-05-20 at 12 42 26 PM

Expected behavior
to see the behavior as the documentation

Screenshots
Add screenshots to help explain your problem. If screenshots aren't applicable to this issue, write "n/a".

Additional details

Reproduction and/or code sample
Provide a link to a reproduction of this issue on https://snack.expo.io or an explanation why you can not. Not including a snack link will result in a significant delay in our ability to address this issue.

ShivamEviView commented 1 year ago

Run this command npm i react-native-picker-select --legacy-peer-deps

OmarKhanfer commented 1 year ago

the solution working fine but I have to flush the cache by using npm start -- --reset-cache

nympheastudio commented 1 year ago

Thanks Shivam, it s working for me too

vijaykhandal1290 commented 1 year ago

Thanks @ShivamEviView

benib3 commented 1 year ago

Thanks @ShivamEviView i was struggling for a while :)

stef1103 commented 11 months ago

A better solution that does not involve installing peer legacy dependencies can be found here: Issue 486