我正在使用 React Native 取消定义导航器
消息标签:
_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
最佳答案
在 SingleConversation 的构造函数中:
constructor(props) {
super(props);
// `navigation` is from props, not `this`
var conversation_id = props.navigation.state.params.id;
}
关于javascript - 使用 React Native 的未定义导航器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50077509/