1import { DrawerItems } from 'react-navigation';
2
3const visibleItems = ['HomeScreen', 'SettingsScreen', 'HelpScreen'];
4
5const getVisible = item => contains(item.key, visibleItems);
6
7const getFilteredAndStyledItems = ({ items, ...other }) => (
8 <DrawerItems
9 items={filter(getVisible, items)}
10 {...other}
11 />
12);
1//custom drawer content
2export default props => {
3 const { state, ...rest } = props;
4 const newState = { ...state} //copy from state before applying any filter. do not change original state
5 newState.routes = newState.routes.filter(item => item.name !== 'Login') //replace "Login' with your route name
6
7 return (
8 <DrawerContentScrollView {...props}>
9 <DrawerItemList state={newState} {...rest} />
10 </DrawerContentScrollView>
11 )
12}
1function DrawerNavigator() {
2 return (
3 <NavigationContainer>
4 <Drawer.Navigator
5 initialRouteName="Home"
6 drawerContent={props => {
7 const filteredProps = {
8 ...props,
9 state: {
10 ...props.state,
11 routeNames: props.state.routeNames.filter(routeName => {
12 routeName !== 'Home';
13 }),
14 routes: props.state.routes.filter(route => route.name !== 'Home'),
15 },
16 };
17 return (
18 <DrawerContentScrollView {...filteredProps}>
19 <DrawerItemList {...filteredProps} />
20 </DrawerContentScrollView>
21 );
22 }}>
23 <Drawer.Screen name="Notifications" component={ProfileScreen} />
24 <Drawer.Screen name="Notifications2" component={ProfileScreen} />
25 <Drawer.Screen name="Home" component={StackNavigator} />
26 </Drawer.Navigator>
27 </NavigationContainer>
28 );
29}
30