I have Question. How can I pass specific param from each screen to the StackNavigator header in order to come out different kind of components when reached the screen.
I have done some research about this kind of question, but there are not much info that can help me. So I posted here to find some help, hope there are someone who can guide me. Thanks a lot.
const mainNav = TabNavigator({
Home: {
screen: HomeScreen,
param:{
tabval:1
}
},
Live: {
screen: LiveScreen,
param:{
tabval:2
}
},
Radio: {
screen: RadioScreen,
param:{
tabval:3
}
},
} );
function DifferentComponents(tabval){
if(tabval == 1){
//do something
}else if(tabval == 2){
//do something
}else{
//do something
}
}
export const mainStack = StackNavigator({
Home: {
screen: mainNav,
navigationOptions: {
header: (
<View style={styles.topnavscrollview}>
<View style={{width:300}}>
<ScrollView horizontal={true} showsHorizontalScrollIndicator={false}>
{this.DifferentComponents(tabval)} <-- Change this when switch to Live tab or others
</ScrollView>
</View>
</View>
),
},
},
Content: { screen: ContentScreen },
});