How can I set a default screen for a nested Stack-Navigator in React-Native-Navigation v5?

Viewed 235

I am using a stack navigator within a bottemtabbar and I want to set a default screen in the stack navigator. I'm using React-Native-Navigation v5, so I'll have to create the Navigator like this:

const Stack = createStackNavigator();

<Stack.Navigator
    screenOptions={{
      headerShown: false,
    }}>
    <Stack.Screen name="Feed" component={Feed} />
    <Stack.Screen name="Profile" component={Profile} />
    <Stack.Screen name="NewPost" component={NewPost} />
</Stack.Navigator>

I tried using initialRouteName, but when I open a screen in the Stack Navigator, then go back to anther Tab in my Tab Navigator and then go back to the tab with the Stack Navigator, it still shows the same Stack.Screen I viewed last (I want it to show a specific start screen each time).

Navigators:

Tab-Navigator:

  • Tab1:

    • Stack-Navigator
      • Screen1
      • Screen 2
  • Tab2:

    • (Just a Tab.Screen)
1 Answers

Have you tried,

<Stack.Navigator initialRouteName="Feed"></Stack.Navigator>
Related