Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to toggle react-navigation drawer

I am using react-navigation https://reactnavigation.org/ for my first react-native project. I would like to toggle my drawer (open & close), but I have no idea how I can achieve this. I've been looking at the documentation from reactnavigation.org, but can't really find any hints.

like image 987
user7667437 Avatar asked Dec 01 '22 12:12

user7667437


1 Answers

As by React Navigation(v2)

To open and close drawer, use the following helpers to open and close the drawer:

this.props.navigation.openDrawer();
this.props.navigation.closeDrawer();

If you would like to toggle the drawer you call the following:

this.props.navigation.toggleDrawer();

Each of these functions, behind the scenes, are simply dispatching actions:

this.props.navigation.dispatch(DrawerActions.openDrawer());
this.props.navigation.dispatch(DrawerActions.closeDrawer());
this.props.navigation.dispatch(DrawerActions.toggleDrawer());
like image 150
Jeeva Avatar answered Dec 15 '22 17:12

Jeeva