Bottom Bar + Drawer Navigation . If I want to implement these both together, which should implement first ?
- Bottom bar then Drawer navigator OR
- Drawer then Bottom Navigator
Anyone please answer with proper explanation.... Thanks
Bottom Bar + Drawer Navigation . If I want to implement these both together, which should implement first ?
Anyone please answer with proper explanation.... Thanks
first should be drawer ideally and then tabs.
But it all depends upon your business requirement.
https://snack.expo.dev/@gaurav1995/nesting-navigators-%7C-react-navigation
check the above snack, have implemented.
import * as React from 'react';
import { Button, View } from 'react-native';
import { createDrawerNavigator } from '@react-navigation/drawer';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
function HomeScreen({ navigation }) {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Button
onPress={() => navigation.navigate('Notifications')}
title="Go to notifications"
/>
</View>
);
}
function SettingsScreen({ navigation }) {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Button
onPress={() => navigation.navigate('Notifications')}
title="Go to notifications"
/>
</View>
);
}
function PlaceHome({navigation}){
return(
<Tab.Navigator screenOptions={{headerShown:false}} >
<Tab.Screen name="Home" component={HomeScreen} />
<Tab.Screen name="Settings" component={SettingsScreen} />
</Tab.Navigator>
)
}
function NotificationsScreen({ navigation }) {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Button onPress={() => navigation.goBack()} title="Go back home" />
</View>
);
}
const Drawer = createDrawerNavigator();
const Tab = createBottomTabNavigator();
export default function App() {
return (
<NavigationContainer>
<Drawer.Navigator useLegacyImplementation initialRouteName="DummyHome">
<Drawer.Screen name="DummyHome" component={PlaceHome} />
<Drawer.Screen name="Notifications" component={NotificationsScreen} />
</Drawer.Navigator>
</NavigationContainer>
);
}
Hope it helps