mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-11 10:59:55 +08:00
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.
This commit is contained in:
24
types/react-navigation/index.d.ts
vendored
24
types/react-navigation/index.d.ts
vendored
@@ -476,7 +476,7 @@ export interface LayoutEvent {
|
||||
}
|
||||
|
||||
interface NavigationContainerProps {
|
||||
navigation: NavigationProp<any, NavigationAction>
|
||||
navigation?: NavigationProp<any, NavigationAction>
|
||||
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<any>,
|
||||
contentOptions?: {
|
||||
activeTintColor?: string,
|
||||
@@ -531,7 +531,7 @@ export function DrawerNavigator(
|
||||
*/
|
||||
export interface TabNavigatorConfig {
|
||||
tabBarComponent?: React.ReactElement<any>,
|
||||
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<any>;
|
||||
headerBackTitle?: string|null;
|
||||
headerTitle?: string | React.ReactElement<any>;
|
||||
headerBackTitle?: string | null;
|
||||
headerTruncatedBackTitle?: string;
|
||||
headerRight?: React.ReactElement<any>;
|
||||
headerLeft?: React.ReactElement<any>;
|
||||
@@ -586,18 +586,18 @@ export interface TabNavigatorScreenOptions {
|
||||
tabBarVisible?: boolean;
|
||||
tabBarIcon?: React.ReactElement<any>;
|
||||
tabBarLaben?: string
|
||||
|React.ReactElement<any>
|
||||
| ((options: {focused: boolean, tintColor: string}) => React.ReactElement<any>)
|
||||
| React.ReactElement<any>
|
||||
| ((options: { focused: boolean, tintColor: string }) => React.ReactElement<any>)
|
||||
;
|
||||
}
|
||||
|
||||
export interface DrawerNavigatorScreenOptions {
|
||||
title?: string;
|
||||
drawerLabel?: string
|
||||
|React.ReactElement<any>
|
||||
| ((options: {focused: boolean, tintColor: string}) => React.ReactElement<any>)
|
||||
| React.ReactElement<any>
|
||||
| ((options: { focused: boolean, tintColor: string }) => React.ReactElement<any>)
|
||||
;
|
||||
drawerIcon?: React.ReactElement<any>
|
||||
| ((options: {focused: boolean, tintColor: string}) => React.ReactElement<any>)
|
||||
| ((options: { focused: boolean, tintColor: string }) => React.ReactElement<any>)
|
||||
;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user