Search code examples
react-nativenavigation-drawerreact-native-navigationreact-navigation-drawer

How to set react-native drawer header icon ('Hamburger') to the right side?


I set the drawer right-side, but the hamburger icon, in the screen header, stays default left side, Is there any property to pass through to change position to the right? I know it should be done with configuring a custom header, but I don't want to overengineer my small project.


Solution

  • import {DrawerActions} from '@react-navigation/native';
    
    <Drawer.Navigator
          screenOptions={{
            drawerPosition: 'right',
          }}>
          <Drawer.Screen
            name="Home"
            component={Home}
            options={{
              headerStyle: {
                backgroundColor: 'orange',
              },
              headerTintColor: 'black',
              headerLeft:false,
              headerRight: () => (
                <TouchableOpacity  onPress={() => navigation.dispatch(DrawerActions.openDrawer())}>
                  <Icon name="menu" size={30} color="black" />
                </TouchableOpacity>
              ),
            }}
          />
          <Drawer.Screen name="Standings" component={Standings} />
        </Drawer.Navigator>
    

    It worked for me.