I can set the header options "universally" for some things, for example, make the title color white:
const SettingsScreen = () => <View><Text>SettingsScreen...</Text></View>
const List = () => <View><Text>List...</Text></View>
const Item = () => <View><Text>Item...</Text></View>
const navigationOptions = {
header: {
style: {
backgroundColor: '#fff'
}
},
}
const ListScreens = StackNavigator({
List: { screen: List, navigationOptions: navigationOptions },
Item: { screen: Item, navigationOptions: navigationOptions },
});
const SettingsContainer = StackNavigator({
Settings: { screen: SettingsScreen },
});
const LoggedIn = DrawerNavigator({
Main: { screen: ListScreens },
Settings: { screen: SettingsContainer },
});
What is the best practice of adding hamburger menus to all routes at the DrawerNavigation menu level? I want this pop to open the box. There is no access to props.navigation if I am not inside each of the components ... just state and parameters. Do I need to duplicate the code in each of these files?
static navigationOptions = {
title: ({ state }) => {
if (state.params.mode === 'info') {
return `${state.params.user} Contact Info`;
}
return `Chat with ${state.params.user}`;
},
header: ({ state, setParams }) => {
let right = (
<Button
title={`${state.params.user} info`}
onPress={() => setParams({ mode: 'info' })}
/>
);
if (state.params.mode === 'info') {
right = (
<Button
title="Done"
onPress={() => setParams({ mode: 'none' })}
/>
);
}
return { right };
},
..
DOCS HERE
relevant questions (possibly):
https://github.com/react-community/react-navigation/issues/165
arcom source
share