Reputation: 6560
I am trying to dynamically change the title of my react-navigation
navigation bar:
componentDidMount() {
InteractionManager.runAfterInteractions(() =>
this.props.navigation.setParams({ title:"New Title" });
});
}
Although I can verify this function is called, the navigation bar does not change to "New Title."
Am I passing the wrong object into the setParams()
function?
Upvotes: 1
Views: 878
Reputation: 7563
react navigation doesn't read the title from the params
object. It uses the navigationOptions
static property on the component.
You can set that property to a function:
static navigationOptions = ({navigation}) => {
title: navigation.state.params.title
}
Then when you set the param the title should change.
Upvotes: 4