反应道具中误导的流类型错误 [英] Missleading flow type error in react props

查看:66
本文介绍了反应道具中误导的流类型错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用react-redux更改了添加到组件DispatchProps中的功能的实现,我得到了以下错误:

Having changed the implementation of a function added to the DispatchProps of a component using react-redux I got the following error:

yarn run v1.13.0
$ flow

Cannot call this.props.<prop> because:
 • Either property <prop> is missing in ExternalProps [1].
 • Or property <prop> is missing in ConnectProps [2].

但是,道具是DispatchProps的一部分;与提到的道具相交:type Props = ExternalProps & ConnectProps & DispatchProps.

However, the prop was part of the DispatchProps; which is intersected with the mentioned props: type Props = ExternalProps & ConnectProps & DispatchProps.

推荐答案

问题显然是函数实现中的类型错误.这似乎导致流程没有将功能添加到道具,然后以这种方式抱怨-重构功能以在更细粒度的级别使用类型可以正确地报告问题.

The issue was apparently a type-error in the implementation of the function. This seems to lead to flow not adding the function to the props and then complaining in this way - refactoring the function to use types at a more granular level had flow reporting the issue correctly.

这篇关于反应道具中误导的流类型错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆