Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

403
Vistas
React Native Drawer Navigation always closing automatically

I have a React Native app using React Navigation. The app already consists of a Tab Navigator nesting Stack Navigators. Now I additionally wanted to add a Drawer Navigation at the very top level, displaying a custom drawer content.

So my hierarchy would be DrawerNavigator (nesting the 1 TabNavigator) > TabNavigator (nesting 5 StackNavigators) > Stack Navigator (nesting individual number of actual content screens).

To accomplish this, I have added the Drawer Navigator at the top level, nesting the existing Tab Navigator:

<Drawer.Navigator
    initialRouteName="MainTabNav"
    drawerContent={props => <DrawerMenu {...props} />}
    screenOptions={{
        headerShown: false,
    }}>
    <Drawer.Screen name="MainTabNav" component={MainTabNavigator} />
</Drawer.Navigator>

Here is my issue now: When I swipe from the left to the right, the Drawer shows up and I can see my custom drawer navigation component as long as I leave my finger on the screen. Whenever I remove the finger from the screen, the drawer navigation automatically closes again.

Furthermore, calling navigation.dispatch(DrawerActions.openDrawer()) from a Pressable inside the Stack Navigator does nothing - the drawer will just not open at all.

...
import {useNavigation} from '@react-navigation/native';
import {DrawerActions} from '@react-navigation/native';

const DrawerMenuButton = props => {
  const navigation = useNavigation();

  return (
    <Pressable
      onPress={() => {
        navigation.dispatch(DrawerActions.toggleDrawer());
      }}>
...

Does anyone have any idea for a solution to this problem?

Thanks a lot and best regards The Smart Home Maker

P.S.: My configuration is as follows

"react": "17.0.2",
"react-native": "0.64.2",
"@react-navigation/drawer": "^6.1.3",
"@react-navigation/native": "^5.1.7",
"@react-navigation/stack": "^5.2.14",
"@react-navigation/bottom-tabs": "^5.5.2",
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I saw the version for @react-navigation/native is v5. But drawer is v6. So please downgrade it to v5. It will work.

npm install @react-navigation/drawer@^5.x

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda