0

I'm trying to control whether or not my StackNavigator header appears via this.props.navigation.state.params.

I have a screen with the following navigationOptions:

static navigationOptions = ( {navigation} ) => ({
    header: navigation.state.params.headerConfig,
});

and I navigate to the screen as follows:

<Button
      onPress={() => navigate('MyScreen', { headerConfig: _____} ) }
      title="Continue"
/>

, where ____ is what I am unsure about. If I put null then the header disappears, but what can I put there if I don't want the header to disappear?

I tried entering HeaderProps instead of ____.

Any help or alternative approaches would be much appreciated.

1 Answer 1

2

If you don't want it do disappear then don't set it to null, leave it undefined and you will get the default one.

static navigationOptions = ({navigation}) => {
    if (navigation.state.params.hideHeader) {
        return {header: null}
    }
    return {title: 'Home'}
}
Sign up to request clarification or add additional context in comments.

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.