Search code examples
react-navigationreact-navigation-stackreact-navigation-v5

How to remove double header with react-navigation?


My React Native 0.61.5 uses react-navigation 5.1. Here is the root navigation code:

const BTab = createBottomTabNavigator();
const Stack = createStackNavigator();
export default function App() {

  //const Appscreen = () => (<AppScreen data={data}/>);

  return (
    <NavigationContainer>
      <Stack.Navigator InitialRouteName="Splash">
        <Stack.Screen name="Splash" component={SplashScreen}}/>
        <Stack.Screen name="App" component={AppScreen} } />
      </Stack.Navigator>

    </NavigationContainer>
  );
}

The component AppScreen return a stack like this:

return (
    <NavigationContainer independent={true}>
      <BTab.Navigator>
          <BTab.Screen name="Event" component={Eventstack} />
          <BTab.Screen name="Group" component={Groupstack} />
          <BTab.Screen name="Contact" component={Contactstack} />
      </BTab.Navigator>
    </NavigationContainer>
  );

I notice that on the screen there are double header:

enter image description here

How can I remove the App header and only keep the Group?


Solution

  • add with the screen that you want to hide the header.

    options= {{
      headerShown: false
    }}
    

    For further reading, kindly have a look at https://reactnavigation.org/docs/stack-navigator/#headershown