【问题标题】:Expo navigation Drawer doesnt open , what can i do to solve this?Expo 导航抽屉打不开,我该怎么做才能解决这个问题?
【发布时间】:2023-02-03 08:24:50
【问题描述】:

问题 :

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

代码 :

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

【问题讨论】:

    标签: react-native expo react-navigation navigation-drawer slidingdrawer


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2020-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-24
      • 2013-10-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多