Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change navigation bar title when view loads

I need to read one value and use it to set title in navigation bar.
I am using react-native-router-flux and I also use redux.
I navigate to view where I set language and fire redux action.
All views receive new state and in render() method I can call:

console.log(this.props.language.language)

This is set through redux. And I want to change navigation bar title like:

Actions.refresh({title: I18n.t('main', {locale: this.props.language.language})})

But this slows down application and don't work.
But don't know where to put it if not in render method.

like image 254
1110 Avatar asked Nov 08 '22 01:11

1110


1 Answers

You can change navigation title by setting navigation params as follows:

this.props.navigation.setParams({
    title: 'YOUR_DESIRED_TITLE_HERE',
});
like image 158
gypsicoder Avatar answered Nov 15 '22 12:11

gypsicoder