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.
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());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With