1
votes

export default class LoginScreen extends React.component{

render () {
     return (
         <Button = {()=>this.props.navigation.navigate('Home', {number: 5} />
      )
}

}

class HomeScreen extends React.Component { render(){ return( {this.props} // I would like to display the number passed ) } }

2
please provide a proper code snippet - Sachin Kammar

2 Answers

1
votes

I found the answer, thank you so much for the help. To display I used {this.props.route.params.name}

0
votes

Initialise:-

constructor(props) {
    super(props);
    this.params = this.props.navigation.state.params;
}

Retrieve data:-

console.log(this.params.name);
console.log(this.params.about);

If you are showing in any element, you also show like

<Text>{this.params.name}</Text> 

Here is the complete example code. Maybe it will help you to understand it

https://www.google.com/amp/s/aboutreact.com/react-native-pass-value-from-one-screen-to-another-using-react-navigation/amp/