react-nativeexporeact-navigationnavigation-drawerslidingdrawer

Expo navigation Drawer doesnt open , what can i do to solve this?


Issue :

Side bar doesnt open when i press the bars icon near navigation Header and i dont recieve any error messages in console. the bars icon is supposed to trigger a drawer sliding from the left when pressed on.

Code :

import * as React from "react";
import { Button, View } from "react-native";
import { createDrawerNavigator } from "@react-navigation/drawer";
import { NavigationContainer } from "@react-navigation/native";

function HomeScreen({ navigation }) {
  return (
    <View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
      <Button
        onPress={() => navigation.navigate("Notifications")}
        title="Go to notifications"
      />
    </View>
  );
}

function NotificationsScreen({ navigation }) {
  return (
    <View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
      <Button onPress={() => navigation.goBack()} title="Go back home" />
    </View>
  );
}

const Drawer = createDrawerNavigator();

export default function App() {
  return (
    <NavigationContainer>
      <Drawer.Navigator initialRouteName="Home">
        <Drawer.Screen name="Home" component={HomeScreen} />
        <Drawer.Screen name="Notifications" component={NotificationsScreen} />
      </Drawer.Navigator>
    </NavigationContainer>
  );
}

Here is a screenshot


Solution

  • I'm using expo and came across the same issue, "react-native-reanimated" is added as part of drawer navigation setup ( https://reactnavigation.org/docs/drawer-navigator/) and adding the relevant plugin into the babel.config.js resolved the issue e.g., plugins: ["nativewind/babel", "react-native-reanimated/plugin"]