React Native 世博会导航抽屉打不开,我该怎么办?

pcrecxhr  于 2023-02-05  发布在  React
关注(0)|答案(1)|浏览(197)

发布日期:
当我按下导航标题附近的条形图标时,侧边栏不会打开,并且我在控制台中没有收到任何错误消息。条形图标应该在按下时触发抽屉从左侧滑动。
代码:

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>
  );
}

juzqafwq

juzqafwq1#

我正在使用expo,遇到了同样的问题,“react-native-reanimated”被添加为抽屉导航设置(https://reactnavigation.org/docs/drawer-navigator/)的一部分,并将相关插件添加到babel.config.js中解决了该问题,例如plugins: ["nativewind/babel", "react-native-reanimated/plugin"]

相关问题