undefined is not an object (evaluating 'RNGestureHandlerModule.State'

前端 未结 20 771
Happy的楠姐
Happy的楠姐 2020-12-01 04:43

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

相关标签:
20条回答
  • 2020-12-01 04:45
    1. remove node_modules and package-lock.json
    2. npm install
    3. npm install --save react-navigation
    4. npm install --save react-native-gesture-handler
    5. react-native link
    0 讨论(0)
  • 2020-12-01 04:45

    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!

    0 讨论(0)
  • 2020-12-01 04:48

    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

    0 讨论(0)
  • 2020-12-01 04:48

    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

    0 讨论(0)
  • 2020-12-01 04:50

    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 :)

    0 讨论(0)
  • 2020-12-01 04:50

    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

    0 讨论(0)
提交回复
热议问题