I m trying to pass the title of each page from react navigation to the header component but with no luck. I am pretty sure that i am sending the prop corectly but i dont know how to used i tried with {props.headerTitle} but no luck.
Header Component:
export default function Header() {
return (
<View style={styles.header}>
<Text>{props.headerTitle}</Text>
</View>
);
}
Navigation
<AuthStack.Navigator initialRouteName={RegisterLogin}>
<AuthStack.Screen
name="RegisterLogin"
component={RegisterLogin}
options={({navigation, route}) => ({
headerShown: false,
headerTitle: (props) => <Header {...props} />,
headerStyle: {
backgroundColor: 'red',
elevation: 0,
shadowOpacity: 0,
borderBottomWidth: 0,
},
})}
/>
<AuthStack.Screen
name="Login"
component={LoginWithContext}
options={({navigation, route}) => ({
headerTitle: (props) => <Header {...props} />,
headerStyle: {
backgroundColor: 'red',
elevation: 0,
shadowOpacity: 0,
borderBottomWidth: 0,
},
})}
/>