undefined is not an object (evaluating 'navigation.navigate')

非 Y 不嫁゛ 提交于 2020-05-23 11:55:29

问题


I am trying to navigate from one screen to other screen inside tabbar in react native. But, I am getting following error

  ButtonClickCheckFunction = () => {
    const { navigation } = this.props;
    navigation.navigate('detailsScreen', { detailsScreen: jsonData });
  }

Any suggestions?

For main screens, In tab bar we have created stack,

    const AppStack = createAppContainer(createDrawerNavigator({
      Dashboard: {
        screen: ProfileStack,
      },
      Connect: {
        screen: Connect,
      },
      screen1: {
        screen: Screen1,
      }

});

But, In Dashboard screen we are showing tabbar. I am working with tab2. So, From tab2, I have details screen. In that details screen I have to show navigation bar with back button arrow like custom image.

So, How to fix this?


回答1:


If you post more code, we'll be able to better answer your question.

From the error message though, it seems like you're not properly creating the component so that the navigation property is set. You'll need to make sure to wrap the component using the withNavigation higher order component.

export default withNavigation(MyComponent);


来源:https://stackoverflow.com/questions/55221232/undefined-is-not-an-object-evaluating-navigation-navigate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!