I have a view, lets say DynamicView. I am trying to push the same view(DynamicView)in navigator with different params.
this.props.navigator.push({
component: DynamicView,
params: {} //Different params
})
...
export default connect(mapStateToProps, mapDispatchToProps)(DynamicView)
DynamicView is connected with the redux flow. But I cannot access the latest state in the pushed component.
I want to know, whether is this the right thing to do? If yes, how can i access the latest state in the pushed component which is same as parent. If no, then is there any other approach to create the new route dynamically.
Any help is appreciated. Thanks.
React Native v0.40
A React Navigation navigator, such as a StackNavigator for example, can easily support that. As confirmed here by the creator of React Navigation.
So say you're doing some basic navigation using a StackNavigator. You would do something like this:
export const SimpleApp = StackNavigator({
MyDynamicView: { screen: DynamicView }
... other routes ...
});
And then, from your React components (including the DynamicView component) you can navigate to the MyDynamicView
route as many times as you want, with different params:
navigation.navigate('MyDynamicView, { username: 'John' })
or
navigation.navigate('MyDynamicView, { username: 'John2' })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With