Closed bittu1028 closed 8 months ago
@bittu1028 @ramisalem - what are you experiencing exactly? which platform? which deps? etc...
Once update react-native-picker to v2.1.0, then it will show this error which probably cause by this package
Current env: "@react-native-picker/picker": "^2.1.0", "react-native-picker-select": "^8.0.4",
Try this as a quick troubleshooting checklist: (in order)
Device -> Erase all content and settings
@react-native-community/picker
replace with @react-native-picker/picker
npm uninstall @react-native-community/picker
cd ios && pod install
Product -> Clean Build Folder
Double check that your package.json
does not include any old/duplicate picker deps (dev too) at different versions.
You can also try to repeat the steps starting at 5, by completely removing your local node modules rm -rf node_modules
then npm install
and at 6 by removing your installed Pods cd ios && rm Podfile.lock && rm -rf Pods
then pod install --repo-update
to get fresh versions of all deps. This will take longer to do, but usually clears out any old stuff.
If you are still seeing the same error after all of this, it might be another dep in your package.json that is including the old community picker in its source.
If you follow the current readme, this library will end up installing 2 versions of @react-native-picker/picker. That's what causes this issue.
I got it working by installing @react-native-picker/picker with ^1.8.3
in package.json. It has to match this library's dependency exactly or it will install duplicates and you'll get the Invariant Violation error.
I believe the dependency configuration around @react-native-picker/picker could be improved in this library.
I made a PR using @react-native-picker/picker as a peerDependency. You could also just upgrade the dependency to the latest in the current package.json (^2.1.0
), but I think this is a good use of peerDependencies.
If you are using Yarn, you can solve this temporarily by forcing react-native-picker-select to resolve to ^2.1.0 instead of ^1.8.3 using yarn resolutions.
In package.json, add:
"resolutions": {
"react-native-picker-select/@react-native-picker/picker": "^2.1.0"
},
newest version uses 2.4
Same issue