未定义不是对象(评估"navigation.navigate") [英] undefined is not an object (evaluating 'navigation.navigate')

查看:283
本文介绍了未定义不是对象(评估"navigation.navigate")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在本机中从一个屏幕导航到选项卡栏内的另一个屏幕. 但是,我收到以下错误消息

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 });
  }

有什么建议吗?

对于主屏幕,我们在标签栏中创建了堆栈,

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

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

});

但是,在仪表板"屏幕中,我们显示了标签栏.我正在使用tab2.因此,从tab2,我有详细信息屏幕.在该详细信息屏幕中,我必须显示带有后退按钮箭头的导航栏,例如自定义图像.

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?

推荐答案

如果您发布更多代码,我们将能够更好地回答您的问题.

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

不过,从错误消息来看,您似乎没有正确创建组件,因此未设置navigation属性.您需要确保使用 withNavigation 高阶组件.

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);

这篇关于未定义不是对象(评估"navigation.navigate")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆