React Native Navigation issue

36 Views Asked by At

undefined is not an object (evaluating 'this.props.navigation')

When I try to click and navigate to next screen getting above error

1

There are 1 best solutions below

0
Hisham Mubarak On

When you are moving to another from component from a component or loading the first component, you need to pass the navigation prop down to the next component.

Example <Item navigation={this.props.navigation}/> Above line will pass your navigation to 'Item' component and you can use the navigation within your item component, and you won't receive the current error that you are receiving.

Another way is to create a root stackNavigator if you are using react-navigation package for app's navigation, and pass that Stacknavigator to your App.js, and thus all your components will go through the same navigation, and you wont need to pass navigation between screen as they'll all have them by default