undefined is not an object (evaluating 'RNGest

2020-01-29 04:39发布

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 error like this.

Here is my Navigation code

import { createStackNavigator } from 'react-navigation';

import Home from './screens/Home';
import WeatherDetail from './screens/WeatherDetail';


const Navigation = createStackNavigator({
  Home: { screen: Home },
  WeatherDetail: {
  screen: WeatherDetail
 } 
});

export default Navigation;

And here is the App.js codes

 import Navigator from './Router';


 export default class App extends Component {
   render() {
     return (
       <View style={styles.container}>
         <Navigator />
       </View>
     );
    }
  }

If I remove the navigator component from the App.js and replace it with a Text the application runs without any error.

18条回答
虎瘦雄心在
2楼-- · 2020-01-29 04:47
  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
查看更多
走好不送
3楼-- · 2020-01-29 04:47

This worked well for me as well.
1) npm install react-navigation
2) npm install react-native-gesture-handler
3) npm intstall
4) react-native link

uninstall the app

5) react-native run-android

查看更多
劳资没心,怎么记你
4楼-- · 2020-01-29 04:48

I used this in the CLI to solve the issue

cd iOS
pod install

cd ..
react-native unlink react-native-gesture-handler
查看更多
Melony?
5楼-- · 2020-01-29 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

查看更多
对你真心纯属浪费
6楼-- · 2020-01-29 04:49

I get the same error on ios from RN v0.60

The following worked for me:

cd ios
pod install
查看更多
聊天终结者
7楼-- · 2020-01-29 04:51

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
查看更多
登录 后发表回答