I'm using React Navigation 5.
At the top I have a Drawer navigator, with the following screens:
<Drawer.Navigator>
<Drawer.Screen name="One" component={StackNavigatorOne} />
<Drawer.Screen name="Two" component={StackNavigatorTwo} />
<Drawer.Screen name="Three" component={StackNavigatorThree} />
<Drawer.Navigator/>
Within StackNavigatorOne, I have a stack navigator,
<Stack.Navigator>
<Stack.Screen name="Screen1" component={Screen1} />
<Stack.Screen name="Screen2" component={Screen2} />
<Stack.Screen name="Screen2" component={Screen3} />
</Stack.Navigator>
From the Drawer Navigator, if the user navigates to Stack Navigator One
, and then moves to Screen2
, the Screen2 stays on top. Now, if the user opens drawer navigation and again clicks on Stack Navigator One
, he will be on Screen 2 only because Screen 2 is on top in that stack.
However, what I need is that when the user clicks the DrawerScreen One
, it should always go to Screen1
of StackNavigatorOne
. Is it possibe to reset the screens in StackNavigatorOne
irrespective of which screen the user is on, when he click the DrawerScreen One
in the drawer?
Thanks.
initialRouteName
for the stack makes this possible? - Shayan