我正在使用undefine navigator使用React Native
MessageTabs:
_onPressItem = (item) => {
const { navigate } = this.props.navigation;
//console.log(JSON.stringify(item));
navigate('SingleConversation', {id: item.id})
};
在SingleConversation的构造函数中,我得到:
var conversation_id = this.navigation.state.params.id;
我正在
TypeError: Cannot read property 'state' of undefined
答案 0 :(得分:1)
在SingleConversation的构造函数中:
constructor(props) {
super(props);
// `navigation` is from props, not `this`
var conversation_id = props.navigation.state.params.id;
}