This.props.navigation.dispatch(DrawerActions.openDrawer);this.props.navigation.dispatch(DrawerActions.closeDrawer);this.props.navigation.dispatch(DrawerActions.toggleDrawer);Before creating the React Native drawer navigation, first go through the where we discussed the react-navigation installation process. React Native Drawer Navigation ExampleCreate two separate classes 'DashboardScreen' and 'WelcomeScreen' in the react native app to display on screen. Add these screens to createStackNavigator and add ' md-menu' icon of ' react-native-vector-icons/Ionicons' package.
On pressing the menu icon, call navigation.openDrawer method to open drawer.Now, import createDrawerNavigator from ' react-navigation' package and implement createDrawerNavigator. After that add the stack navigation screen over it.
![Outside Outside](/uploads/1/2/5/5/125503999/147318233.png)
@Ronnyrr - you can always call openDrawer by dispatching the action like @theohdv above. You don't have access to the helper if the screen you're trying to call it from is in a different navigator subtree. You can reorganize where the drawer navigator is so that it's shared among screens that would want to open the drawer if you like. This tutorial is a deep dive of React Navigation, which is the way to do in app navigation. It also goes into the best practices for styling your app and how to collaborate with designers for styling. The code for this tutorial is in GitHub.
Snack:Follow these steps to replicate:. Press 'Open Drawer' button on Page 1.
Select page2 in the drawer menu. Press 'Go to Page 3' on Page 2. Press 'Open Drawer' on Page 3Current BehaviorCurrently, when you press 'Open Drawer' on Page 3, the drawer opens as expected, however the navigator takes you back to Page 2, rather than leaving you on Page 3 where you opened the drawer from.Expected BehaviorPerhaps this is less expected and more desired but I'd like to be able to open the menu without navigating back to Page 2. The use case is when I have pages that are not top-level, thus are not included in the drawer menu. However, I'd like the user to always have access to the drawer if they'd like to navigate elsewhere - but if they close the menu without selecting another page, it should return them to where they left off, not navigate them back up the stack.QuestionIs there a way I can either resolve this issue, or another method to hiding screens from the drawer navigation but still allow them to be 'pushable' from any screen in the drawer?
While this works for this particular example, I probably didn't explain my use case the best. The problem is I don't know what screen will be opening Page 3, so I need it accessible from every page in the drawer navigation, hence the way I originally structured my navigation. What I'd prefer is for any screen NOT visible in the drawer, to PUSH on top of whichever screen navigates to it. But also from those pushed screens be able to open the drawer, while preserving the current stack (aka not popping). With your solution I'd have to create a stack for each drawer item.–Oct 26 '18 at 13:14.