首页 > 解决方案 > React Native:tabBarVisible 选项设置为 false 但不隐藏 tabBar

问题描述

我正在使用 React Navigation v5,但是当我将选项设置tabBarVisible为 false 时tabBar并没有隐藏。这是一段不起作用的代码。我不知道怎么了。

..

  <Tabs.Navigator screenOptions={screenOptions} initialRouteName="Home">
      <Tabs.Screen
        name="Home"
        component={Home}
        options={({ route }) => ({
          tabBarVisible: false, // <-- This not working
          tabBarIcon: (props) => (
            <TabIcon
              {...props}
              title="Home"
              Icon={{
                name: "home",
                IconComponent: AntDesign,
              }}
            />
          ),
        })}
      />
...

任何建议。

标签: reactjsreact-nativereact-native-navigation

解决方案


这应该适用于最新版本的软件包:

  <Tab.Screen
    name="Settings"
    component={SettingsScreen}
    options={{ tabBarStyle: { display: 'none' } }}
  />

推荐阅读