undefined is not an object (evaluating 'RNGestureHandlerModule.State'
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.
Solution 1:
- remove node_modules and package-lock.json
npm install
npm install --save react-navigation
npm install --save react-native-gesture-handler
react-native link
Solution 2:
If you are using react-link to link your dependencies:
- 0pen your ios Podfile and delete all yout linked dependencies: pod 'xxxxxxx', :path => '../node_modules/xxxxx
- Close Xcode
- In your /ios folder run "pod update"
- In your project source run "react-native link"
- Open Xcode and Clean Build Folder from Xcode Menu -> Product
- Run your application from Xcode
- Link manually the dependency "react-native-gesture-handler" into your Xcode Project following steps in documentation: https://facebook.github.io/react-native/docs/linking-libraries-ios
- Now run your application from Xcode, you should be fine.