torgeadelin/react-native-animated-nav-tab-bar

Possible to hide a specific tab?

macist-m opened this issue · 2 comments

Hello, with regular tab navigation, it is possible to hide a specific tab form the bar with this...

<Tab.Navigator
      screenOptions={({ route }) => ({
        tabBarButton: [
          "Route1ToExclude",
          "Route2ToExclude"
        ].includes(route.name)
          ? () => {
              return null;
            }
          : undefined,
      })}
    >

Yet this is not working with react-native-animated-nav-tab-bar...

İs it possible to hide a tab with stack navigation nested in?

@macist-m
I hope you find my hack helpful!
Bottom Implement it in the Stack Navigator nested in the Navigator.

// add your stack navigator 
import React, { useLayoutEffect } from "react";
import { getFocusedRouteNameFromRoute } from "@react-navigation/native";

const navName: any = getFocusedRouteNameFromRoute(route);

useLayoutEffect(() => {
switch (navName) {
case "The stack screen name you want to hide.....":
navigation.setOptions({ tabBarVisible: false });
break;

  default:
    navigation.setOptions({ tabBarVisible: true });
    break;
}
return;
}, [navigation, route]);

Stale issue message