Disable swipe gesture from opening the navigation drawer using react-navigation

Set edge width to 0.

React Navigation 6

In screen options:

<Drawer.Navigator
  screenOptions={{
    swipeEdgeWidth: 0,
  }}
>
  {/* screens */}
</Drawer.Navigator>

React Navigation 5

In your createDrawerNavigator config:

const drawerNavigator = createDrawerNavigator({
  Home: {
    screen: Home
  }
}, 
{
  edgeWidth: 0
})

I found a way to disable it, it won't open but still can be closed by swiping...

this is my code

  contentComponent: SideMenu,
  initialRouteName: 'Stack',
  drawerPosition: 'left',
  drawerWidth: '80%',
  edgeWidth: -100 // this is where the magic happens :))

React Navigation V5

This version changed how we set the properties of the Navigation Drawer so the other answers will no longer work. Instead of setting the properties in

createDrawerNavigator()

Set them in the JSX tag like so

<Drawer.Navigator edgeWidth={0} >

This will disable swipe to open while keeping swipe to close enabled.


You can use the drawerLockMode in the screen navigation options using the option locked-open

locked-open: the drawer will stay opened and not respond to gestures. The drawer may still be opened and closed programmatically

Other options can be viewed here

static navigationOptions = {
     drawerLockMode: 'locked-open',
}