I have the following route structure:
StackNavigator
-StackNavigator
-TabNavigator
--Tab1
--Tab2
When I find Tab1 -> Route 1 -> Route 2 -> Tab2
and get back to Tab1
, the active route is 2 instead of initialRoute
1.
I do the following:
tabBarOnPress: ({ scene }) => {
const { route } = scene;
const tabRoute = route.routeName;
const { routeName } = route.routes[0];
navigation.dispatch(NavigationActions.navigate({ routeName: tabRoute }));
navigation.dispatch(NavigationActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName }),
],
}));
},
but the problem is that it shows first Route 2
, and then go to Route 1
.
How can I use reset previous tabs / screens, so when I switch the tab always, to show the initial route directly.
source
share