Reputation:
I've two pages: Page1: Two Variables CUR1:
render() {
const { navigation } = this.props;
const cur1 = navigation.getParam('cur1', 'ABC');
Page2:
<Button badge rounded light style={styles.ok} onPress={() =>navigate('Home', {cur1:this.state.cur1})} >
<Text style={styles.oks}>OK</Text>
</Button>
On double checking this.state.cur1
is not empty, but after redirection to Page1 navigation.getParam shows default value
Upvotes: 0
Views: 42
Reputation: 1433
You can send data to other screen by using following code
<Button
title="button"
onPress={() => { this.props.navigation.navigate('Page2', {
letter: 'A'
});}}
/>
Receive data in page 2 like below,
const { params } = this.props.navigation.state;
this.letter = params ? params.letter : null;
Upvotes: 1
Reputation: 116
You need to pass through params , Below is the example.
navigate("Home",{},
{
type: "Navigate",
routeName: "SecondView",
params: {cur1:this.state.cur1
}
Upvotes: 0