I am working on a mobile app and need your help. I want to hide bottom tab bar in "auth" route name. I have tried several methods from stackoverflow and google but it didn’t work.
My Code:
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/
import React from 'react';
import {View} from 'react-native';
import Auth from './views/Auth';
import AuthState from './context/auth/AuthState';
import {NavigationContainer} from '@react-navigation/native';
import {createMaterialBottomTabNavigator} from '@react-navigation/material-bottom-tabs';
import Home from './views/Home';
const Tab = createMaterialBottomTabNavigator();
const App = () => {
return (
<AuthState>
<NavigationContainer>
<Tab.Navigator initialRouteName="auth">
<Tab.Screen name="auth" component={Auth} />
<Tab.Screen name="home" component={Home} />
</Tab.Navigator>
</NavigationContainer>
</AuthState>
);
};
export default App;
3
Answers
Issue solved by Nesting Navigators
Well a better solution can be to create layout components
After reading your requirement, I suggest you to try an Authentication flow approch written by ‘React-Navigator’ API instead of putting ‘Auth’ page in the same Tab Navigator.
The main idea of that is using 2 Navigators.
However, to make this flow available, you need to add Global State Management library like Redux / React Context to handle which navigator is showing.