mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-21 21:31:12 +08:00
Overloaded navigate method to handle new navigation options parameters
This commit is contained in:
16
types/react-navigation/index.d.ts
vendored
16
types/react-navigation/index.d.ts
vendored
@@ -420,12 +420,18 @@ export interface NavigationEventSubscription {
|
||||
export interface NavigationScreenProp<S> {
|
||||
state: S;
|
||||
dispatch: NavigationDispatch;
|
||||
goBack: (routeKey?: (string | null)) => boolean;
|
||||
navigate: (
|
||||
routeName: string,
|
||||
goBack: (routeKey?: string | null) => boolean;
|
||||
navigate(options: {
|
||||
routeName: string;
|
||||
params?: NavigationParams;
|
||||
action?: NavigationAction;
|
||||
key?: string;
|
||||
}): boolean;
|
||||
navigate(
|
||||
routeNameOrOptions: string,
|
||||
params?: NavigationParams,
|
||||
action?: NavigationAction
|
||||
) => boolean;
|
||||
action?: NavigationAction,
|
||||
): boolean;
|
||||
setParams: (newParams: NavigationParams) => boolean;
|
||||
addListener: (
|
||||
eventName: string,
|
||||
|
||||
@@ -60,6 +60,7 @@ class StartScreen extends React.Component<NavigationScreenProps> {
|
||||
return (
|
||||
<View>
|
||||
<TouchableOpacity onPress={this.navigateToNextScreen} />
|
||||
<TouchableOpacity onPress={this.navigateDifferentlyToNextScreen} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -70,6 +71,13 @@ class StartScreen extends React.Component<NavigationScreenProps> {
|
||||
};
|
||||
this.props.navigation.navigate(ROUTE_NAME_NEXT_SCREEN, params);
|
||||
}
|
||||
private readonly navigateDifferentlyToNextScreen = (): void => {
|
||||
const params = {
|
||||
id: this.props.navigation.state.params && this.props.navigation.state.params.id,
|
||||
name: this.props.navigation.state.params && this.props.navigation.state.params.s,
|
||||
};
|
||||
this.props.navigation.navigate({routeName: ROUTE_NAME_NEXT_SCREEN, params});
|
||||
}
|
||||
}
|
||||
|
||||
const ROUTE_NAME_NEXT_SCREEN = "NextScreen";
|
||||
|
||||
Reference in New Issue
Block a user