11

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:

screenshot

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?

5 Answers 5

19

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

Sign up to request clarification or add additional context in comments.

1 Comment

As for React Navigation 1.0.0-beta.11 header : { visible : false} doesn't work. Use header : null instead.
11

Starting from v1.0.0-beta.9, use the following,

static navigationOptions = {
    header: null
}

Comments

3

This worked for me:

headerMode: 'none'

3 Comments

doesn't work for me in "react-navigation": "^1.0.0-beta.7"
I have "react-navigation": "^1.0.0-beta.9" and the method -> static navigationOptions = { header: false } work for me.
@DanielArenas You're my hero dude
1

This works for me to hide the navigation:

static navigationOptions = {
    header: null
 };

Comments

1

This Worked for me, i am working on android side in react native version 0.45

static navigationOptions = {
    header: null
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.