导出默认类LoginScreen扩展React.component{
render () {
return (
<Button = {()=>this.props.navigation.navigate('Home', {number: 5} />
)
}
}
类HomeScreen扩展了React。组件{render(({返回({this.props}//我想显示通过的号码)}}
我找到了答案,非常感谢您的帮助。为了显示,我使用了{this.props.route.params.name}
初始化:-
constructor(props) {
super(props);
this.params = this.props.navigation.state.params;
}
检索数据:-
console.log(this.params.name);
console.log(this.params.about);
如果你在任何元素中显示,你也会像一样显示
<Text>{this.params.name}</Text>
这是完整的示例代码。也许它会帮助你理解
https://www.google.com/amp/s/aboutrect.com/react-native-pass-value-from-on-screen-to-another-using-react-navigation/amp/