how to display the initial screen when navigating between navigators

Viewed 36

I have a TabNavigator and a StackNavigator. I made a RootStackNavigator to navigate between the two navigators:

<RootStack.Screen
  name="AddOrderNavigator"
  component={AddOrderNavigator}
  options={{ animationEnabled: true, gestureEnabled: false, headerLeft: null }}
/>
<RootStack.Screen
  name="App"
  component={AppNavigator}
  options={{ animationEnabled: true, gestureEnabled: false, headerLeft: null }}
/>

All works good, except when I navigate from one to another; it doesn't display the initial screen, it keeps the old state and displays the screen I was in before I go to the other.

Edit:

So the solution was to specify the screen I wanted to navigate to:

navigation.push("AddOrderNavigator", {screen: 'DeliveryTypeScreen'});

0 Answers
Related