Index.js
<View>
<TouchableOpacity
onPress={() => this.props.navigation.navigate('Product', { select: 1 })}
>
<Text>navigate</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => this.props.navigation.push('Product', { select: 1 })}
>
<Text>push</Text>
</TouchableOpacity>
</View>
Product.js
componentDidMount() {
console.log(this.props.navigation.state.params);
// when navigate, returns null
// when push, returns Object { "select": 1 }
}
When navigating from Index to Product, I want to pass a param: select.
When I use navigation.push()
, Product receives the param.
But I don't want to use push
cuz I don't wanna add a screen here.