i have bottom tab stack....in each stack there are either single screen or nested stack navigator.
Problem:
first tab - Home screen second tab - MyDetailsStack(createStackNavigator) - detailScreen1 (initialRoute) - detailScreen2
Goal: when user visits detail detailScreen2.... then goes back go homescreen and clicks back second tab....i need to reset the second tab to show initial route it is pointing which is detailScreen1. At this moment what ever screen i left (that is detailScreen2) is shown.
Please check the expo for the problem.
https://snack.expo.dev/@rosnk/nested-route-reset-on-tabchange
Currently tried solution:
- tried adding following code:
<Tab.Screen
name="MyDetailsTabStack"
component={MyDetailsStack}
options={{
title: 'My Details',
tabBarLabel: 'My Details',
}}
listeners={({ navigation, route }) => ({
tabPress: (e) => {
navigation.dispatch(
CommonActions.reset({
index: 1,
routes: [
{ name: 'DetailScreen1' },
{
name: 'DetailScreen2',
},
],
})
);
},
})}
/>
tried solution reference to this stack suggestion: How to reset a Stack in a different Tab using React Navigation 5.x