【问题标题】:How to hide tabBar in specific Screen in React Navigation 6?如何在 React Navigation 6 的特定屏幕中隐藏 tabBar?
【发布时间】:2021-12-21 12:32:02
【问题描述】:

如何在react-navigation 6 的特定屏幕中隐藏标签栏... 不改变导航结构,因为它是the only option available in the docs here

【问题讨论】:

    标签: react-native react-navigation react-navigation-v6


    【解决方案1】:

    有时我使用这种方法

    import { getFocusedRouteNameFromRoute } from ‘@react-navigation/native’;
    
    
     export const MainNavigator = () => {
      const getTabBarVisibility = (route) => {
        const routeName = getFocusedRouteNameFromRoute(route);
        const hideOnScreens = [SCREENS.REVIEW_ORDER, SCREENS.ORDER_PAYMENT]; // put here name of screen where you want to hide tabBar
        return hideOnScreens.indexOf(routeName) <= -1;
      };
      return (
        <Tab.Navigator>
          <Tab.Screen
            name={SCREENS.ORDER}
            component={OrderNavigator}
            options={({ route }) => ({
              tabBarVisible: getTabBarVisibility(route),
            })}
          />
          <Tab.Screen name={SCREENS.REWARDS} component={SweetRewardsNavigator} />
          <Tab.Screen name={SCREENS.MY_ACCOUNT} component={MyAccountNavigator} />
        </Tab.Navigator>
      );
    };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-10
      • 1970-01-01
      相关资源
      最近更新 更多