【问题标题】:Navigating to another stack group in NavigationContainer导航到 NavigationContainer 中的另一个堆栈组
【发布时间】:2021-09-29 14:11:24
【问题描述】:

在我的 App.tsx 中,我正在使用 createNativeStackNavigator,我试图关闭“Project_Creation”模式并导航到 Main

    <NavigationContainer>
      <Stack.Navigator>
        <Stack.Group>
          <Stack.Screen name="Main" component={DrawerNavigator} options={{ headerShown: false }} />
          <Stack.Screen name="Details" component={ChannelDetails} />
          <Stack.Screen name="Profile" component={Profile} />
        </Stack.Group>
        <Stack.Group screenOptions={{ stackPresentation: 'modal', headerShown: false }}>
          <Stack.Screen
            options={{ headerTitle: 'Create Project' }}
            name="Project_Creation"
            component={ProjectCreationNavigator}
          />
        </Stack.Group>
      </Stack.Navigator>
    </NavigationContainer>

我不确定是不是因为 createNativeStackNavigator 不像 createStackNavigator 那样可自定义,或者我无法从 ProjectCreationNavigator 中的一个屏幕导航到另一个堆栈组,但它不断出现错误。

有了 navigation.dismiss() 我得到了

navigation.dismiss() is not a function

用 navigation.reset({index: 0, name: "Main"}) 我明白了

undefined is not an object

我很想知道如何导航到“主要”。

【问题讨论】:

    标签: react-native react-navigation


    【解决方案1】:

    更新::

    我意识到了问题所在。在单独的导航器组件中,我包装了 NavigationContainer。当我删除它时它起作用了

    【讨论】:

    • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
    猜你喜欢
    • 1970-01-01
    • 2019-10-08
    • 2013-07-23
    • 2021-09-02
    • 1970-01-01
    • 2020-07-27
    • 1970-01-01
    • 2013-04-29
    • 2018-11-04
    相关资源
    最近更新 更多