Merge pull request #26374 from dawnmist/react-navigation/fix-header-props

[react-navigation]: Add missing fields required for custom header use in v2.x.
This commit is contained in:
Mine Starks
2018-06-13 09:49:33 -07:00
committed by GitHub
2 changed files with 22 additions and 0 deletions
+2
View File
@@ -622,6 +622,7 @@ export interface NavigationScene {
isStale: boolean;
key: string;
route: NavigationRoute;
descriptor: NavigationDescriptor;
}
export interface NavigationTransitionProps {
@@ -1086,6 +1087,7 @@ export interface NavigationDescriptor<Params = NavigationParams> {
key: string;
state: NavigationLeafRoute<Params> | NavigationStateRoute<Params>;
navigation: NavigationScreenProp<any>;
options: NavigationScreenOptions;
getComponent: () => React.ComponentType;
}
@@ -1,5 +1,6 @@
import * as React from 'react';
import {
Text,
TouchableOpacity,
View,
ViewStyle,
@@ -469,3 +470,22 @@ const BottomStack = createBottomTabNavigator({
}
}
});
const CustomHeaderStack = createStackNavigator({
Page1: { screen: Page1 },
Page2: { screen: Page2 }
},
{
navigationOptions: {
header: headerProps => {
const { scene } = headerProps;
const { options } = scene.descriptor;
const { title, headerStyle, headerTitleStyle } = options;
return (
<View style={headerStyle}>
<Text style={headerTitleStyle}>{title}</Text>
</View>
);
}
}
});