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.
You can do it via 2 methods;
1: Set options
to be a variable from your screen and keep your current code:
<Stack.Screen
name="Label"
component={Component}
options={Component.navigationOptions}
/>
// component
static navigationOptions = {
title: 'find',
};
2: By using setOptions
in your component:
<Stack.Screen
name="News"
component={News}
options={{
title: 'Default',
}}
/>
// component
this.props.navigation.setOptions({title: 'find'});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With