在使用NavigationStackScreenComponent类型注释对屏幕组件进行类型检查时,如何合并组件道具的类型注释?

时间:2019-11-05 13:30:34

标签: typescript react-native react-navigation

以下是版本4.x的React Navigation文档中可用的示例

import { NavigationStackScreenComponent } from 'react-navigation-stack';

type Params = { userId: string };

type ScreenProps = { language: string };

const ProfileScreen: NavigationStackScreenComponent<
  Params,
  ScreenProps
> = props => {
  // ...
};

ProfileScreen.navigationOptions = {
  headerTitle: 'Profile',
};

在打字稿世界中我仍然是菜鸟,但试图使其适应我的React Native Projects。 我遇到的问题是NavigationStackScreenComponent泛型接受导航参数和screenProps的类型,但是我无法(也许有,但我找不到它!)为组件prop添加类型注释。

0 个答案:

没有答案
相关问题