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

前端 未结 20 773
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:59

    I struggled with this and none of the above answers worked for me. Here's what I had to do:

    • Delete your ios folder entirely.
    • Delete your node_modules folder and package-lock.json.
    • Restart your computer.
    • Run react-native eject to re-create your native code folders.
    • Run npm install
    • Run react-native link
    • Run npm run start -- --reset--cache
    • Now run react-native run-ios
    0 讨论(0)
  • 2020-12-01 05:04

    Since I am not allowed to comment, I am posting it here. This is the answer by @Amiri Houssem but I am adding one more thing:

    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

    If there is an error even after these 5 steps, check android/settings.gradle and change that line to this:

    project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
    
    0 讨论(0)
  • 2020-12-01 05:06

    maybe someone come here because same problem as me.

    i got this error because i'm using react-navigation version 3.x, in that version stackNavigator is change to createStackNavigator and should use createAppContainer(createStackNavigator)

    im fix it just like mr.amiri said but im not delete my node_module im just follow step 3 - 5

    0 讨论(0)
  • 2020-12-01 05:07

    I used this in the CLI to solve the issue

    cd iOS
    pod install
    
    cd ..
    react-native unlink react-native-gesture-handler
    
    0 讨论(0)
  • 2020-12-01 05:07

    Even though react-native-gesture-handler is present in node_modules folder, we need to add it to path or install it again. Then link with native code.

    1) npm install --save react-native-gesture-handler

    success Saved 1 new dependency.
    info Direct dependencies
    └─ react-native-gesture-handler@1.0.15
    info All dependencies
    └─ react-native-gesture-handler@1.0.15
    

    2) react-native link

    rnpm-install info Linking react-native-gesture-handler ios dependency 
    rnpm-install info Platform 'ios' module react-native-gesture-handler has been
     successfully linked 
    rnpm-install info Linking react-native-gesture-handler android dependency 
    rnpm-install info Platform 'android' module react-native-gesture-handler has
     been successfully linked
    

    3) react-native run-android or react-native run-ios

    0 讨论(0)
  • 2020-12-01 05:12

    From the official doc:

    If you're on React Native >= 0.60, you need to disable autolinking for react-native-gesture-handler first. To disable autolinking for it, create a react-native.config.js file in the root of your project with the following content:

    module.exports = {
      dependencies: {
        'react-native-gesture-handler': {
          platforms: {
            android: null,
            ios: null,
          },
        },
      },
    };
    

    If your are using React 0.60, just omit this official doc. Follow following steps:

    1. rm react-native.config.js if exist
    2. react-native link react-native-gesture-handler
    3. cd ios && pod install && cd ..
    4. react-native run-ios
    0 讨论(0)
提交回复
热议问题