React Navigation V5 Hide Bottom Tabs

后端 未结 8 1454
轻奢々
轻奢々 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 07:03

    You will have to restructure your navigation by having your Tab Navigator nested in the Stack Navigator. Following the details here hiding-tabbar-in-screens

    This way it's still also possible to have a Stack Navigator nested in yourTab Navigator. SettingsStack

    With this when the user is on the Setting screen and also the Update detail screen, the tab bar is visible but on the Profile screen, the tab bar is not.

    import Home from './components/Home';
    import Settings from './components/Settings';
    import UpdateDetails from './components/UpdateDetails';
    import Profile from './components/Profile';
    
    import * as React from 'react';
    import { NavigationContainer } from '@react-navigation/native';
    import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
    import { createStackNavigator } from '@react-navigation/stack';
    
    const Stack = createStackNavigator();
    const StackSettings = createStackNavigator();
    const Tab = createBottomTabNavigator();
    
    function SettingsStack() {
        return (
            <StackSettings.Navigator>
                <StackSettings.Screen name="Settings" component={Settings} />
                <StackSettings.Screen name="UpdateDetails" component={UpdateDetails} />
            </StackSettings.Navigator>
        )
    }
    
    function HomeTabs() {
      return (
        <Tab.Navigator>
          <Tab.Screen name="Home" component={Home} />
          <Tab.Screen name="Settings" component={SettingsStack} />
        </Tab.Navigator>
      );
    }
    
    
    export default function App() {
      return (
        <NavigationContainer>
          <Stack.Navigator>
            <Stack.Screen name="Home" component={HomeTabs} />
            <Stack.Screen name="Profile" component={Profile} />
          </Stack.Navigator>
        </NavigationContainer>
      );
    }
    
    0 讨论(0)
  • 2021-01-05 07:17

    just follow as what the documentation suggests: https://reactnavigation.org/docs/hiding-tabbar-in-screens/

    0 讨论(0)
提交回复
热议问题