这是将堆栈导航器和抽屉导航器一起使用的最佳方法吗?

发布于 2025-01-26 00:29:08 字数 1081 浏览 3 评论 0原文

我已经在React Native中编程了很短的时间,我对React-Navigation一无所知。经过很多尝试之后,我设法将堆栈导航器与自定义抽屉导航器(侧菜单)一起使用,但这似乎很奇怪,因为我的堆栈像屏幕一样在菜单抽屉内。

我的堆栈:

const SignedInStack = () => (
  <Stack.Navigator>
    <Stack.Screen name='Confluence' component={Confluence} />
    <Stack.Screen name='QRCode' component={Main} />
  </Stack.Navigator>
)

在drawermenu中:

const DrawerMenu = () => (
  <Drawer.Navigator
    screenOptions={{ headerShown: false }}
    drawerContent={(props) => <CustomDrawerContent {...props} />}
    detachInactiveScreens={false}
  >
    <Drawer.Screen
      name="SignedInStack"
      component={SignedInStack}
      options={{
        drawerItemStyle: { height: 0 }
      }}
    />
    <Drawer.Screen
      name="QRCode"
      component={Main}
    />
  <Drawer.Navigator/>
);

在app.js中:

const App = () => (
  <NavigationContainer>
    <DrawerMenu />
  </NavigationContainer>
);

以前我在堆栈中使用抽屉菜单,但是该应用程序存在导航问题。

I've been programming in React Native for a short time, and I know little about react-navigation. After trying a lot I managed to use stack navigator with a custom drawer navigator (side menu), but this seems to be very strange because my stack is inside my menu drawer like a screen.

My stack:

const SignedInStack = () => (
  <Stack.Navigator>
    <Stack.Screen name='Confluence' component={Confluence} />
    <Stack.Screen name='QRCode' component={Main} />
  </Stack.Navigator>
)

In the DrawerMenu:

const DrawerMenu = () => (
  <Drawer.Navigator
    screenOptions={{ headerShown: false }}
    drawerContent={(props) => <CustomDrawerContent {...props} />}
    detachInactiveScreens={false}
  >
    <Drawer.Screen
      name="SignedInStack"
      component={SignedInStack}
      options={{
        drawerItemStyle: { height: 0 }
      }}
    />
    <Drawer.Screen
      name="QRCode"
      component={Main}
    />
  <Drawer.Navigator/>
);

In the App.js:

const App = () => (
  <NavigationContainer>
    <DrawerMenu />
  </NavigationContainer>
);

Previously I use my drawer menu inside my stack, but the app had navigation problems.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文