简体   繁体   English

使用 React Native 的未定义导航器

[英]Undefined navigator using React Native

I'm getting undefine navigator usign React Native我正在取消定义导航器使用 React Native

MessageTabs:消息标签:

 _onPressItem = (item) => { 
  const { navigate } = this.props.navigation;

   //console.log(JSON.stringify(item));
  navigate('SingleConversation', {id: item.id})
};

In the constructor of SingleConversation i get :在 SingleConversation 的构造函数中,我得到:

var conversation_id = this.navigation.state.params.id; var session_id = this.navigation.state.params.id;

I'm getting我越来越

TypeError: Cannot read property 'state' of undefined

In your constructor of SingleConversation:在 SingleConversation 的构造函数中:

constructor(props) {
  super(props);
  // `navigation` is from props, not `this`
  var conversation_id = props.navigation.state.params.id;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM