简体   繁体   中英

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

 <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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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