Combining Navigators
Implementation Example
Section titled “Implementation Example”const Stack = createStackNavigator();const Tab = createBottomTabNavigator();const Drawer = createDrawerNavigator();
function TabNavigator() { return ( <Tab.Navigator> <Tab.Screen name="Home" component={HomeScreen} /> <Tab.Screen name="Feed" component={FeedScreen} /> </Tab.Navigator> );}
function DrawerNavigator() { return ( <Drawer.Navigator> <Drawer.Screen name="Main" component={TabNavigator} /> <Drawer.Screen name="Profile" component={ProfileScreen} /> </Drawer.Navigator> );}
function App() { return ( <NavigationContainer> <Stack.Navigator> <Stack.Screen name="Main" component={DrawerNavigator} options={{ headerShown: false }} /> <Stack.Screen name="Details" component={DetailsScreen} /> <Stack.Screen name="Modal" component={ModalScreen} options={{ presentation: "modal" }} /> </Stack.Navigator> </NavigationContainer> );}Best Practices for Combining Navigators
Section titled “Best Practices for Combining Navigators”- Keep nesting to a minimum (2-3 levels max)
- Use a root stack navigator for modals and authentication flows
- Consider using a switch navigator for auth flows (though deprecated, you can implement your own)
- Be mindful of navigation state complexity