From 66d3ea01bfd549f080a82c49c8ad3bcc275cd3d1 Mon Sep 17 00:00:00 2001 From: agentile Date: Tue, 9 May 2017 20:24:17 -0700 Subject: [PATCH 1/3] 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) ; } From db7d524bd2b6d32d7a305231394e2228cef05111 Mon Sep 17 00:00:00 2001 From: Alex Gentile Date: Tue, 9 May 2017 22:23:46 -0700 Subject: [PATCH 2/3] Update index.d.ts reverted formatting --- types/react-navigation/index.d.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 8ef38a6312..35dba11bf1 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -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) ; } From f5733a87591ea2c03540357a31ed5b46f2600d0c Mon Sep 17 00:00:00 2001 From: Alex Gentile Date: Tue, 9 May 2017 22:51:00 -0700 Subject: [PATCH 3/3] Removed null from headerBackTitle prop Null is unnecessary as headerBackTitle is already optional. --- types/react-navigation/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 35dba11bf1..129bfaca66 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -570,7 +570,7 @@ export interface StackNavigatorScreenOptions { title?: string; headerVisible?: boolean; headerTitle?: string|React.ReactElement; - headerBackTitle?: string|null; + headerBackTitle?: string; headerTruncatedBackTitle?: string; headerRight?: React.ReactElement; headerLeft?: React.ReactElement;