I have a custom title in my (simple) React Navigation StackNavigator, looks like this:
const RootStack = StackNavigator({
Home: {
screen: HomeScreen
}
}, {
navigationOptions: {
headerTitle: <GradientHeader title={this.state.navigation.title} />
}
});
But this returns undefined is not an object (evaluating 'this.state.navigation')
How can I pass the views' unique titles to the custom header?
per the docs, you need to give navigationOptions
as function to access navigation
:
navigationOptions: ({ navigation }) => ({
headerTitle: <GradientHeader title={navigation.state.params.title} />,
}),
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.