3
votes

I'm using a tab navigator and drawer navigator in a react native app. I need to have the drawer navigator open when one of the tabs is pressed. For example, the last tab named 'account' should open up the drawer.

// drawer navigation
const AppDrawerNavigator = createDrawerNavigator({
  Account: AccountScreen,
});

// tab navigation
const AppTabNavigator = createBottomTabNavigator({
  Home: {
    screen: HomeScreen,
  },
  Account: {
    screen: AppDrawerNavigator,
  }
});

With my code right now, the app is simply navigating to the account screen when the account tab is pressed, instead of opening up the drawer. Is there a way to do this?

1

1 Answers

0
votes

I found my answer on this question > React Native - Accessing drawer navigation outside of AppNavigator

I created a NavigationService and added the following to the service.

function openDrawer(routeName, params) {
  _navigator.dispatch(DrawerActions.openDrawer());
}