I've been using react-navigation for almost half a year, but I still don't understand the nesting part of it. How the navigation prop is inherited, how to communicate, etc..
I created a demo on snack, from the redux example app.
Demo
I'd like to understand these:
What happens with the navigation prop if I navigate to a child navigator?
How to navigate from a child navigators screen to the parents screen or the parents other child's screen
How to remove a child navigator from the state?
The simplest example: On a login event I reset the navigator with the Main StackNavigator. The problem with this is, that I have to rebuild manually the whole Main state. It would be much easier If I could just remove somehow the Auth StackNavigator and keep the Main Stack.
I wrapped the Main navigation (StackNavigator) component with a redux component as the doc says. It works fine until I navigate into a child component. The navigation props niavigate method stops dispatching redux actions.
I have a Component and a DrawerNavigator inside a StackNavigator. If i navigate into the DrawerNavigator (there is only 1 screen there) from the Component, I can't go back to that Component with this:
this.props.navigation.goBack()
The odd part is that its only impossible inside the screen's component. From the screen's header component its working.
It can always access in props.navigation
.
reset
action is needed in order to navigate to parent/child navigator.
Also, due to #1127 key: null
is required
navigation.replace
is another option for login navigate to main screen if the screens are in same navigator, use reset
if animated transition is required. Or see other methods in #295
navigate
can only navigate to screen in same navigator, refer to answer 3 for other methods.
maybe the component is missing navigation
props
Working Demo
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