DrawerActions reference
DrawerActions is an object containing methods for generating actions specific to drawer-based navigators. Its methods expand upon the actions available in CommonActions.
For screens inside a Drawer Navigator, drawer actions are available as methods on the navigation object.
The following actions are supported:
openDrawer
The openDrawer action can be used to open the drawer pane.
- Static
- Dynamic
navigation.openDrawer();
navigation.openDrawer();
It can also be used with navigation.dispatch:
import { DrawerActions } from '@react-navigation/native';
navigation.dispatch(DrawerActions.openDrawer());
closeDrawer
The closeDrawer action can be used to close the drawer pane.
- Static
- Dynamic
navigation.closeDrawer();
navigation.closeDrawer();
It can also be used with navigation.dispatch:
import { DrawerActions } from '@react-navigation/native';
navigation.dispatch(DrawerActions.closeDrawer());
toggleDrawer
The toggleDrawer action can be used to toggle the drawer pane.
- Static
- Dynamic
navigation.toggleDrawer();
navigation.toggleDrawer();
It can also be used with navigation.dispatch:
import { DrawerActions } from '@react-navigation/native';
navigation.dispatch(DrawerActions.toggleDrawer());
jumpTo
The jumpTo action can be used to jump to an existing route in the drawer navigator.
name- string - Name of the route to jump to.params- object - Screen params to pass to the destination route.
- Static
- Dynamic
navigation.jumpTo('Profile', { user: 'Satya' });
navigation.jumpTo('Profile', { user: 'Satya' });
It can also be used with navigation.dispatch:
import { DrawerActions } from '@react-navigation/native';
navigation.dispatch(DrawerActions.jumpTo('Profile', { user: 'Satya' }));