From 66d3ea01bfd549f080a82c49c8ad3bcc275cd3d1 Mon Sep 17 00:00:00 2001 From: agentile Date: Tue, 9 May 2017 20:24:17 -0700 Subject: [PATCH] fix: navigation prop should be optional When using StackNavigator, there are times when you would like to trigger custom side effects on navigation by setting the "onNavigationStateChange" prop, but don't want to override default navigation. This PR allows for that. --- types/react-navigation/index.d.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 6b263642ff..8ef38a6312 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -476,7 +476,7 @@ export interface LayoutEvent { } interface NavigationContainerProps { - navigation: NavigationProp + navigation?: NavigationProp onNavigationStateChange?: ( preNavigationState: NavigationState, nextNavigationState: NavigationState, @@ -489,7 +489,7 @@ interface NavigationContainerState { export interface NavigationContainer extends React.ComponentClass< NavigationContainerProps -> { + > { router: any } @@ -509,7 +509,7 @@ export function StackNavigator( */ export interface DrawNavigatorConfig { drawerWidth?: number, - drawerPosition?: 'left'|'right', + drawerPosition?: 'left' | 'right', contentComponent?: React.ReactElement, contentOptions?: { activeTintColor?: string, @@ -531,7 +531,7 @@ export function DrawerNavigator( */ export interface TabNavigatorConfig { tabBarComponent?: React.ReactElement, - tabBarPosition?: 'top'|'bottom', + tabBarPosition?: 'top' | 'bottom', swipeEnabled?: boolean, animationEnabled?: boolean, lazy?: boolean, @@ -556,7 +556,7 @@ export interface TabNavigatorConfig { initialRouteName?: string, order?: string[], paths?: any // TODO: better def - backBehavior?: 'initialRoute'|'none' + backBehavior?: 'initialRoute' | 'none' } export function TabNavigator( @@ -569,8 +569,8 @@ export function TabNavigator( export interface StackNavigatorScreenOptions { title?: string; headerVisible?: boolean; - headerTitle?: string|React.ReactElement; - headerBackTitle?: string|null; + headerTitle?: string | React.ReactElement; + headerBackTitle?: string | null; headerTruncatedBackTitle?: string; headerRight?: React.ReactElement; headerLeft?: React.ReactElement; @@ -586,18 +586,18 @@ export interface TabNavigatorScreenOptions { tabBarVisible?: boolean; tabBarIcon?: React.ReactElement; tabBarLaben?: string - |React.ReactElement - | ((options: {focused: boolean, tintColor: string}) => React.ReactElement) + | React.ReactElement + | ((options: { focused: boolean, tintColor: string }) => React.ReactElement) ; } export interface DrawerNavigatorScreenOptions { title?: string; drawerLabel?: string - |React.ReactElement - | ((options: {focused: boolean, tintColor: string}) => React.ReactElement) + | React.ReactElement + | ((options: { focused: boolean, tintColor: string }) => React.ReactElement) ; drawerIcon?: React.ReactElement - | ((options: {focused: boolean, tintColor: string}) => React.ReactElement) + | ((options: { focused: boolean, tintColor: string }) => React.ReactElement) ; }