将TProps传递给withApollo HOC的正确方法是什么?

时间:2019-04-07 21:51:52

标签: react-native flowtype react-apollo flow-typed

我的问题:我正在努力进行一些本来会很简单的事情:我有一个react-native项目,其中我使用了react-apollo,flow和flow-typed ,并且在我使用withApollo HOC的方式中遇到了一个令流程满意的问题。我收到的流错误是:

Missing type annotation for TProps. TProps is a type parameter declared in function type [1] and was implicitly
instantiated at call of withApollo [2].

我的问题:我想知道如何将TProps传递给withApollo ...什么是正确/最佳方法?

背景: 在我的文件中,我声明了组件的原型:

type type ListCollaboratorsProps = {
  ...
};

我在创建组件时使用ListCollaboratorsProps

class ListCollaborators extends React.Component<ListCollaboratorsProps, ListCollaboratorsState> {

,然后用APollo将其包装后导出组件:

export default withApollo(ListCollaborators);

看到流错误后,我尝试了以下方法:

export default withApollo<ListCollaboratorsProps>(MyApolloComponent);

这似乎使流程变得愉快...但是当我尝试在模拟器中对我的应用进行日光照射时,我得到了这个错误:

Can't find variable: ListCollaboratorsProps

我很困惑,因为在声明组件时我可以使用ListCollaboratorsProps ...

0 个答案:

没有答案
相关问题