function DrawerNavigator() {
return (
<NavigationContainer>
<Drawer.Navigator
initialRouteName="Home"
drawerContent={props => {
const filteredProps = {
...props,
state: {
...props.state,
routeNames: props.state.routeNames.filter(routeName => {
routeName !== 'Home';
}),
routes: props.state.routes.filter(route => route.name !== 'Home'),
},
};
return (
<DrawerContentScrollView {...filteredProps}>
<DrawerItemList {...filteredProps} />
</DrawerContentScrollView>
);
}}>
<Drawer.Screen name="Notifications" component={ProfileScreen} />
<Drawer.Screen name="Notifications2" component={ProfileScreen} />
<Drawer.Screen name="Home" component={StackNavigator} />
</Drawer.Navigator>
</NavigationContainer>
);
}
import { DrawerItems } from 'react-navigation';
const visibleItems = ['HomeScreen', 'SettingsScreen', 'HelpScreen'];
const getVisible = item => contains(item.key, visibleItems);
const getFilteredAndStyledItems = ({ items, ...other }) => (
<DrawerItems
items={filter(getVisible, items)}
{...other}
/>
);
//custom drawer content
export default props => {
const { state, ...rest } = props;
const newState = { ...state} //copy from state before applying any filter. do not change original state
newState.routes = newState.routes.filter(item => item.name !== 'Login') //replace "Login' with your route name
return (
<DrawerContentScrollView {...props}>
<DrawerItemList state={newState} {...rest} />
</DrawerContentScrollView>
)
}