Tap on active Tab should reset initial state for all nested navigators
Ross Miller
Tapping on an active tab should reset the current state in that tab for all nested navigators, recursively.
Currently it calls popToTop() if a StackNavigator is inside the tab. However, this doesn't have the desired effect on a nested DrawerNavigator, SwitchNavigator, or a combination of multiple nested navigators.
(I have a StackNavigator in a DrawerNavigator in a TabNavigator. I want a tap on the active tab to reset the StackNavigator and the DrawerNavigator.)
h
hossein mohammadi
I agree with you, I have this problem in the drawer.
When user click on drawer current item expect to navigate in to current drawer first nested stack, but that doesn't do anything.
Brent Vatne
can you provide an example of an app that does this? i don't think i have seen this elsewhere before. keep in mind that you can override the default behavior and add any other code that you like to it.
Ross Miller
Brent Vatne: The reddit app does this. I couldn't find any other examples. On the first tab, you can tap the reddit icon on the top left to open a drawer menu. If you tap "My Profile" in the drawer menu, you're still on the first tab. Tapping the first tab while it's already active brings you back to the home screen.
The reason we're trying to add this to our app is we have many screens, which fit into 3 verticals, so we have one tab for each of those verticals. These three main screens need to be easily discoverable and very quick to navigate to, hence the tab bar. The remaining screens fit conceptually in the first tab's vertical. And a drawer navigator inside that tab seems like the most intuitive way to represent switching between screens in that vertical. If we used a stack navigator inside the first tab (like Spotify does with their Settings page for instance), it would connote "drilling down" within that vertical instead of "switching screens" within that vertical.
Brent Vatne
Ross Miller: you can add additional behavior to tab press even like this https://reactnavigation.org/docs/bottom-tab-navigator/#tabpress