From f4ee3156b31327cd339dd4d08a135b4d1d2a4b10 Mon Sep 17 00:00:00 2001 From: Janeene Beeforth Date: Fri, 8 Jun 2018 22:03:03 +1000 Subject: [PATCH] Add missing fields required for custom header use in v2.x. See https://github.com/react-navigation/react-navigation/issues/4286 --- types/react-navigation/index.d.ts | 2 ++ .../react-navigation-tests.tsx | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index dd9efa0de4..381f2320dd 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -607,6 +607,7 @@ export interface NavigationScene { isStale: boolean; key: string; route: NavigationRoute; + descriptor: NavigationDescriptor; } export interface NavigationTransitionProps { @@ -1058,6 +1059,7 @@ export interface NavigationDescriptor { key: string; state: NavigationLeafRoute | NavigationStateRoute; navigation: NavigationScreenProp; + options: NavigationScreenOptions; getComponent: () => React.ComponentType; } diff --git a/types/react-navigation/react-navigation-tests.tsx b/types/react-navigation/react-navigation-tests.tsx index 9697e61de8..7563708163 100644 --- a/types/react-navigation/react-navigation-tests.tsx +++ b/types/react-navigation/react-navigation-tests.tsx @@ -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 ( + + {title} + + ); + } + } +});