Javascript 如何从render方法之外的react navigation获取导航参数?
我有一个仪表板组件。有这样一个按钮Javascript 如何从render方法之外的react navigation获取导航参数?,javascript,react-native,react-navigation,Javascript,React Native,React Navigation,我有一个仪表板组件。有这样一个按钮 onPress= {()=>{this.props.navigation.navigate('RenderMeeting',{ meetingName: meeting.meetingname })}} 现在我有了另一个组件,称为渲染会议组件。在标题上显示会议名称。我已经这样做了 constructor(props){ super(props); } static navigationOptions = { t
onPress= {()=>{this.props.navigation.navigate('RenderMeeting',{
meetingName: meeting.meetingname
})}}
现在我有了另一个组件,称为渲染会议组件。在标题上显示会议名称。我已经这样做了
constructor(props){
super(props);
}
static navigationOptions = {
title: this.props.navigation.getParam('meetingName','sdfsdf'),
})
现在,在渲染时,我得到一个未定义的对象,它不是一个计算“RenderMeetingScreen.props.navigate”的对象。我做错了什么
您只需获得如下参数:
this.props.navigation.state.params.meetingName
组成部分
您甚至可以在构造函数中获得它,如下所示:
constructor(props) {
super(props);
const{navigation}=this.props;
this.state = {
title : navigation.getParam('meetingName')
}
}