1

I must do 2 drawer at both sides and a bottom tab navigator. I tried to do it with react-navigation but I couldnt because openDrawer code just opens one of them so I stuck please help me. How can I give drawers ID, key or another method.

React Native


<Button onPress={this.props.navigation.openDrawer}>
<Button/>  //left drawer opens 
<Button onPress={this.props.navigation.openDrawer}>
<Button/>

I tried your code but I got TypeError: undefined is not an object (evaluating 'this.props.navigation.dispatch')

<Button title='open the drawer' onPress={this.props.navigation.dispatch(DrawerActions.openDrawer('drawerOpenLeft'))}></Button>
        <Button title='open the drawer right' onPress={this.props.navigation.dispatch(DrawerActions.openDrawer('drawerOpenRight'))}></Button>

1 Answers1

0

Each drawerNavigator can be positioned and Route named. Position can be set to right or left. Then open the drawer you want through the command.

Example

let LeftSideMenuDrawer = createDrawerNavigator({
...
    drawerOpenRoute: 'LeftSideMenu',
    drawerCloseRoute: 'LeftSideMenuClose',
    drawerToggleRoute: 'LeftSideMenuToggle',
....

Usage

this.props.navigation.dispatch(DrawerActions.openDrawer('LeftSideMenu'));
hong developer
  • 13,291
  • 4
  • 38
  • 68