I have the following stack navigation and screens:
export const HomeStack = createStackNavigator({ Home: HomeScreen, Categories: CategoriesScreen, Products: ProductsScreen, ProductDetails: ProductDetailsScreen, })
I want to hide tabs only in ProductDetailsScreen
export const hideTabBarComponents = [ 'ProductDetails', ] export const MainTabs = createBottomTabNavigator( { Home: HomeStack, Favorite: FavoriteScreen, Account: AccountScreen, Help: HelpScreen, Events: EventsScreen }, { navigationOptions: ({ navigation }) => ({ tabBarIcon: ({ focused, tintColor }) => { ... }, tabBarLabel: ({ focused, tintColor }) => { ... }, tabBarVisible: ! hideTabBarComponents.includes(navigation.state.routeName) }), } );
The problem that can't pass any options to Tab navigation from Stack Navigation
Not all of the stack screens only one of them
Use setVisible from context to make the tabbar hidden.
To hide the navigation navbar with React Native, we set the screenOptions. headerShown option to false .
(React Nav ver6. x) add this code snipet "options={{headerShown: false}}" in "<Tab. Screen />". It will delete header of each tab you add into.
The following code solved the problem:
HomeStack.navigationOptions = ({ navigation }) => { let tabBarVisible = true; let routeName = navigation.state.routes[navigation.state.index].routeName if ( routeName == 'ProductDetails' ) { tabBarVisible = false } return { tabBarVisible, } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With