deadcoder0904
deadcoder0904

Reputation: 8683

Set header to null in navigationOptions using React Navigation in React Native?

I want to set the header to null.

Currently, I am trying to do

const HomeStack = createStackNavigator({
  Home: HomeScreen,
})

HomeStack.navigationOptions = {
  tabBarLabel: 'Home',
  header: null
}

But the above header: null doesn't work.

But the below code does work.

class HomeScreen extends React.Component {
  static navigationOptions = {
    header: null,
  }

  render() {
    ...
  }
}

How do I make it work in HomeStack.navigationOptions?

Also, can I set a global header: null because I don't want header in any of my screens?

Upvotes: 1

Views: 1050

Answers (1)

blitzcom
blitzcom

Reputation: 150

Try something like this (note headerModel: 'none'):

const MainStack = createStackNavigator(
  {
    Home: { screen: Home },
  },
  { initialRouteName: 'Home', headerMode: 'none' }
);

Upvotes: 2

Related Questions