I'm using the official react-navigation to handle my navigation. I have one main TabNavigator for the whole app with two tabs (called HitchhikingMapNavigator and SettingsNavigator below), and each tab has a nested StackNavigator:
const HitchhikingMapNavigator = StackNavigator({
  hitchhikingMap: { screen: HitchhikingMapViewContainer },
  spotDetails: { screen: SpotDetailsViewContainer }
}, {
  navigationOptions: {
    header: {
      visible: false
    }
  }
});
const SettingsNavigator = StackNavigator({
  // some other routes
});
export default AppNavigator = TabNavigator({
  hitchhikingMap: { screen: HitchhikingMapNavigator },
  settings: { screen: SettingsNavigator }
}, {
  navigationOptions: {
    header: {
      visible: false,
    },
 },
});
As you can see, I put the headers' visilibility to false everywhere, even in my HitchhikingMapViewContainer's view:
class HitchhikingMapView extends React.Component {
  static navigationOptions = {
    title: 'Map',
    header: {
      visible: false,
    },
    //...other options
  }
And yet, the header bar is still visible:

If I don't nest the navigators (i.e. if I put this code, skipping the nested one):
export default AppNavigator = TabNavigator({
  hitchhikingMap: { screen: HitchhikingMapViewContainer },
  settings: { screen: SettingsNavigator }
});
then the header is correctly hidden.
So conclusion: I can't make a header not visible when I have two nested navigators. Any ideas?
How do I hide the header in navigation? To hide the navigation header on Press of a Button setOptions({headerShown: false}); In this example, We will create a stack navigator with a single screen which will have a header and has a button to click.
In react navigation 5. x you can hide the header for all screens by setting the headerMode prop of the Navigator to false .
If the navigator was already rendered, navigating to another screen will push a new screen in case of stack navigator. In the above case, you're navigating to the Media screen, which is in a navigator nested inside the Sound screen, which is in a navigator nested inside the Settings screen.
For those who are still looking for the answer, I will post it here.
So two solutions:
1st solution: use headerMode: 'none' in the StackNavigator. This will remove the header from ALL screens in the StackNavigator
2nd solution: use headerMode: 'screen' in the StackNavigator and add header: { visible: false } in the navigationOptions of the screens where you want to hide the header.
More info can be found here: https://reactnavigation.org/docs/en/stack-navigator.html
Starting from v1.0.0-beta.9, use the following,
static navigationOptions = {
    header: null
}
                        This worked for me:
headerMode: 'none'
                        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