Issue
I have recently updated my project to react navigation 5.x. In earlier version we used to set header title as follows :
static navigationOptions = ({ navigation }) => ({
title: 'find',
});
This is not working on React Navigation 5.x. Please Suggest.
Solution
After going through various SO posts and documents I found the following ways to do this -
In the Component using setOptions
this.props.navigation.setOptions({title: 'TitleSetInComponent'});
Can also give a default title in createStackNavigator();
<Stack.Screen
name="myComponent"
component={MyComponent}
options={{
title: 'TitleSetInStackNavigator',
}}
/>
In createStackNavigator(); using navigationOptions as options
<Stack.Screen
name="myComponent"
component={MyComponent}
options={MyComponent.navigationOptions}
/>
// MyComponent
static navigationOptions = {
title: 'TitleSetInComponent',
};
Answered By - Rizwan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.