React Navigation V5 Hide Bottom Tabs

后端 未结 8 1539
轻奢々
轻奢々 2021-01-05 06:35

I would like to be able to hide the tabs on a screen using React Native Navigation v5.

I\'ve been reading the documentation but it doesn\'t seem like they\'ve update

8条回答
  •  滥情空心
    2021-01-05 06:52

    import { createBottomTabNavigator } from "@react-navigation/bottom-tabs"; // version 5.6.1
    import { createStackNavigator } from "@react-navigation/stack"; // version 5.6.2
    

    From my inspection navigation.routes.state.index will have a value when you navigation/push to a second screen so I create a function

    const shouldTabBarVisible = (navigation) => {
      try {
        return navigation.route.state.index < 1;
      } catch (e) {
        return true;
      }
    };
    

    and call it in BottomTab.Screen options

    
         ({
                tabBarIcon: ({ color }) => ,
                tabBarVisible: shouldTabBarVisible(navigation),
            })}
        />
    
    

提交回复
热议问题