mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-24 04:25:34 +08:00
feat: make ScreenProps parametrizable in TypeScript (#6496)
This change allows for the following to be written:
```tsx
const TreatmentPlanDrawerItem = createStackNavigator(
{
Screen: {
screen: Screen,
// t is of type i18next.TFunction via the type casting below.
navigationOptions: ({ screenProps }) => ({
title: screenProps.t('title'),
})
},
} as NavigationRouteConfigMap<
NavigationStackOptions,
NavigationStackProp<NavigationRoute, any>,
{ t: i18next.TFunction }
>
);
```
This commit is contained in:
@@ -482,7 +482,7 @@ declare module 'react-navigation' {
|
||||
| NavigationSwitchAction
|
||||
| { type: 'CHILD_ACTION'; key?: string };
|
||||
|
||||
export type NavigationRouteConfig<Options, NavigationScreenPropType> =
|
||||
export type NavigationRouteConfig<Options, NavigationScreenPropType, ScreenProps = unknown> =
|
||||
| NavigationComponent<Options, NavigationScreenPropType>
|
||||
| (
|
||||
| { screen: NavigationComponent<Options, NavigationScreenPropType> }
|
||||
@@ -494,7 +494,8 @@ declare module 'react-navigation' {
|
||||
}) & {
|
||||
navigationOptions?: NavigationScreenConfig<
|
||||
Options,
|
||||
NavigationScreenPropType
|
||||
NavigationScreenPropType,
|
||||
ScreenProps
|
||||
>;
|
||||
params?: { [key: string]: any };
|
||||
path?: string;
|
||||
@@ -514,10 +515,11 @@ declare module 'react-navigation' {
|
||||
resetOnBlur?: boolean;
|
||||
}
|
||||
|
||||
export interface NavigationRouteConfigMap<Options, NavigationScreenPropType> {
|
||||
export interface NavigationRouteConfigMap<Options, NavigationScreenPropType, ScreenProps = unknown> {
|
||||
[routeName: string]: NavigationRouteConfig<
|
||||
Options,
|
||||
NavigationScreenPropType
|
||||
NavigationScreenPropType,
|
||||
ScreenProps
|
||||
>;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user