With React Navigation Is it possible to define certain routes with a headerMode and others without?
The majority of my pages don't use the header and I found how to turn it off globally.
export const App = StackNavigator({
PhotoView: {
screen: Photos
},
ListView: {
screen: List
}
}, {
headerMode: 'none'
});
But if I wanted to show the header on ListView
for example, how would I do that?
I've tried several approaches from the docs but no luck.
x you can hide the header for all screens by setting the headerMode prop of the Navigator to false .
Provides a way for your app to transition between screens where each new screen is placed on top of a stack. By default the stack navigator is configured to have the familiar iOS and Android look & feel: new screens slide in from the right on iOS, fade in from the bottom on Android.
You can wrap your app navigator in a root navigator, set navigationOptions.header
to null
to hide all wrapped navigators header, then set navigationOptions.headerTitle
on screen that you want to display header.
This answer is based from react-navigation version v1.0.0-beta.9
const App = StackNavigator({
PhotoView: {
screen: Photos,
},
ListView: {
screen: List,
navigationOptions: {
headerTitle: 'ListView',
},
}
});
export const Root = StackNavigator({
Root: {
screen: App,
navigationOptions: {
header: null,
},
},
});
You can hide the navigator header in the component of the screen attribute with:
static navigationOptions = {
header: null
};
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