Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CreateNavigationDrawer Right Side React Native

How to Make the Navigation Drawer In React Native slide from the right Side, I tried position: right but it doesnt work

 export default createDrawerNavigator({

 Home:{
 screen: AppStackNav,
 navigationOptions: {
  drawerIcon: ({tintColor}) => (
    <Icon name = 'ios-home' style={{fontSize:24, color: tintColor}}/>
  ),
  drawerLabel: "Home",

}},

Setting: {
screen: SettingScreen,
navigationOptions: {
    drawerLabel: "Setting",
    drawerIcon: ({tintColor}) => (
      <Icon name = 'ios-settings' style={{fontSize:24, color: tintColor}}/>
    )}},
{
    contentComponent: CustomDrawerComponent

  },{
   drawerPosition: 'right',}

);
like image 204
othman safadi Avatar asked Jun 11 '26 05:06

othman safadi


2 Answers

You need to add drawerPosition: 'right' inside screenOptions tag. like This <Drawer.Navigator

        initialRouteName="HomeScreen"
        screenOptions={{ headerShown: false, drawerPosition:"right" }}}> 

</Drawer.Navigator>

like image 165
umair ali Avatar answered Jun 14 '26 14:06

umair ali


Closing bracket of component was missing and drawerPosition should be the first parameter after closing bracket of component. Works fine now.

const Hello = createDrawerNavigator({
     Home:{
     screen: AppStackNav,
     navigationOptions: {
      drawerIcon: ({tintColor}) => (
        <Icon name = 'ios-home' style={{fontSize:24, color: tintColor}}/>
      ),
      drawerLabel: "Home",

    }},

    Setting: {
    screen: SettingScreen,
    navigationOptions: {
        drawerLabel: "Setting",
        drawerIcon: ({tintColor}) => (
          <Icon name = 'ios-settings' style={{fontSize:24, color: tintColor}}/>
        )}}
      },{
       drawerPosition: 'right',},
    {
        contentComponent: CustomDrawerComponent

      }

    );
like image 20
ehsan Avatar answered Jun 14 '26 15:06

ehsan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!