'how to set a default value for a headerLeft?

Inside of my component render() method, I'm doing the following:

    if (this.state.text) {
      this.props.navigation.setOptions({
        headerLeft: this.headerLeft,
      });
    } else {
      this.props.navigation.setOptions({
        headerLeft: this.headerDEFAULT,
      });
    }

I would like to leave headerLeft as empty instead of this.headerDEFAULT, to go back to its default state. How can that be done?



Solution 1:[1]

it looks like this is inside of screen then use navigation.setOptions

headerLeft prop is your custom component so you override it

const navigation = useNavigation()
navigation.setOptions({headerLeft: (...props) => null})

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Engazan