I have installed react-navigation in my React Native project. Its a starter project doesn\'t have any codes. But while running project I am facing
npm install
npm install --save react-navigation
npm install --save react-native-gesture-handler
react-native link
I'm answering because none of the above answers were relevant to me.
I got this error because VSCode automatically inserted import { TouchableOpacity } from 'react-native-gesture-handler'
as a dependency in my file when I added a <TouchableOpacity>
element.
Give the last files you edited a once-over just in case there's an import statement you don't expect!
you can check your version of react-native if React Native 0.59 and lower you can
react-native link react-native-gesture-handler
and check your @react-navigation
version in
https://reactnavigation.org/versions
may be its late.
Temporary solution downgrade the version of react navigation:
1- unlink and uninstall react-navigation and the handler
2- add "react-navigation": "^2.18.2" to package.json
3- remove node_modules folder
4- npm i
5- react-native link
see your native react version, if version 0.60 then you must migrate to androidX using a jetifier, follow the steps in this link https://github.com/mikehardy/jetifier
successful for me :)
If you're on React Native >= 0.60:
You should see the following entry in your ios/Podfile
:
pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'
If this line is not there, first run:
react-native link react-native-gesture-handler
ios/Podfile
should now contain a new entry.
Now run this command from iOS directory /ios/
:
pod install
Run your iOS project again either directly using XCode
or react-native run-ios