Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to hide a screen from drawer in react navigation 5

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>
  );
}
Comment

hide screen links in drawerNavigation in react native

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}
  />
);
Comment

hide screen links in drawerNavigation in react native

//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>
    )
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: The data option must be a function. Plain object usage is no longer supported. vue 
Javascript :: how to migrate data from one elasticsearch to another 
Javascript :: list of states js 
Javascript :: Function.prototype.bind polyfill 
Javascript :: nested template strings js 
Javascript :: check internet connection in react 
Javascript :: × Error: Invariant failed: You should not use <Switch outside a <Router 
Javascript :: ask for expo token and save to firebase 
Javascript :: js display property 
Javascript :: sequelize find deleted 
Javascript :: override backswipe behaviour in ios and android react native 
Javascript :: check if localstorage is undefined 
Javascript :: deploy react to azure : web.config 
Javascript :: javascript tousand seperator 
Javascript :: testing jest 
Javascript :: exit node 
Javascript :: selectboxit 
Javascript :: delegate click in jquery 
Javascript :: Substring in Javascript using slice 
Javascript :: mongoose encrypt database using mongoose encrypt package 
Javascript :: Reactjs exemple class component 
Javascript :: remove unused css and js wordpress 
Javascript :: json regex 
Javascript :: search an array with regex javascript find 
Javascript :: java script to send email 
Javascript :: ajax post csrf codeigniter 
Javascript :: how to copy all elements in an array except for the first one in javascript 
Javascript :: append array to array javascript 
Javascript :: remove the last character from a string in JavaScript, 
Javascript :: nohup nodemon 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =