React Native。在反应导航中从BottomTab.Navigator隐藏项目

问题描述 投票:0回答:1

假设我有3页。 HomeSettingsPage

我有

<BottomTab.Navigator>
  <BottomTab.Screen name="Home" component={HomeScreen}/>
  <BottomTab.Screen name="Settings" component={SettingsScreen}/>
  <BottomTab.Screen name="Page" component={PageScreen}/>
</BottomTab.Navigator>

它们的全部3个都显示在底部导航中。

我想从底部导航访问HomeSettings,并从Page页面中的链接访问Home

我的问题是有一种方法可以从底部导航隐藏Page,但仍然从其他页面链接到它并传递道具和数据给它?

我曾尝试从Page中删除<BottomTab.Screen>,但是后来我无法使用navigation.navigate("Page")导航到该页面,因此我需要这样做,以便可以将道具和数据传递到该页面]

以下是来自应用的一些代码。该代码是通过expo

生成的
// App.js
render (
<NavigationContainer
          ref={containerRef}
          initialState={initialNavigationState}
        >
          <Stack.Navigator>
            <Stack.Screen name="Root" component={BottomTabNavigator} />
          </Stack.Navigator>
        </NavigationContainer>
      </View>
)
//bottomTabNavigator component
<RootStack.Navigator initialRouteName={INITIAL_ROUTE_NAME}>
      <RootStack.Screen
        name="Home"
        component={HomeScreen}
        options={{
          title: "Get Started",
          tabBarIcon: ({ focused }) => (
            <TabBarIcon focused={focused} name="md-code-working" />
          ),
        }}
      />
      <RootStack.Screen
        name="Profile"
        component={ProfileScreen}
        options={{
          tabBarVisible: false,
          title: "Your Profile",
          tabBarIcon: ({ focused }) => (
            <TabBarIcon focused={focused} name="md-book" />
          ),
        }}
      />
    </RootStack.Navigator>

谢谢

假设我有3页。主页,设置,页面。我有

javascript react-native navigation react-navigation
1个回答
0
投票

我不确定我是否正确理解您的意思,但是我认为这就是您想要的。

https://reactnavigation.org/docs/stack-navigator/

安装所有内容后,您可以执行以下操作

const RootStackNavigator = () => {
    return(
        <RootStack.Navigator>
            <RootStack.Screen name="main" component = {BottomStackScreen}/>
            <RootStack.Screen name="Page" component={PageScreen} />
        </RootStack.Navigator>
    )
}
© www.soinside.com 2019 - 2024. All rights reserved.