简体   繁体   English

在屏幕之间导航时,本机未传递参数

[英]Params not being passed when navigating between screens react native

I have this button in first screen 我在第一个屏幕中有此按钮

 <Button rounded   title='next'    onPress= {() => navigate('nextScreen', { text: this.props.navigation.state.params.text, name: this.props.navigation.state.params.name})}>

and I want to display the text and the name in nextScreen but there is no result , here is the code 我想在nextScreen中显示文本和名称,但是没有结果,这是代码

 <Text style={{direction: 'rtl', fontSize: 15, padding: 5 }}> • {this.props.navigation.state.params.name}-  {this.props.navigation.state.params.text} </Text>
<Button rounded   title='next'    onPress= {() => navigate('nextScreen', { text: this.props.navigation.state.params.text, name: this.props.navigation.state.params.name})}>

in the above code you are sending text and name as 在上面的代码中,您将文本和名称发送为

{ text: this.props.navigation.state.params.text, name: this.props.navigation.state.params.name}

check weather you are getting text and name from the previous screen.the values should not be null 检查天气,您正在从上一个屏幕获取文本和名称。值不能为null

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

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