I have an expo react native app with react-navigation v3.
I am passing a signOut function from my main App to a header component of one of my stack navigators. I want to pass this header once so I don't want to add it to the navigationOptions for every screen.
I'm having trouble accessing the props in my MainStackNavigator and passing the function down to my component.
Main App
render () {
return (
<View style={styles.container}>
<AppNavigator screenProps={{ signOut: this.signOut }}/>
</View>
);
}
AppNavigator
export default createAppContainer(
createSwitchNavigator({
// You could add another route here for authentication.
// Read more at https://reactnavigation.org/docs/en/auth-flow.html
Main: MainStackNavigator,
},
{
initialRouteName: 'Main'
})
);
MainStackNavigator
export default createStackNavigator({
Home: {
screen: HomeScreen,
}
},{
initialRouteName: 'Home',
defaultNavigationOptions : {
headerTitle: <LogoTitle signOut={this.screenProps.signOut}/>,
headerMode: 'screen',
}
});
So when I am passing in the component LogoTitle, how do I access the screenProps at this point?
headerTitle: (props) => <LogoTitle signOut={props.screenProps.signOut}/>