Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 使用Flowtype覆盖React Redux Connect()_Reactjs_Redux_React Redux_Flowtype_Static Analysis - Fatal编程技术网

Reactjs 使用Flowtype覆盖React Redux Connect()

Reactjs 使用Flowtype覆盖React Redux Connect(),reactjs,redux,react-redux,flowtype,static-analysis,Reactjs,Redux,React Redux,Flowtype,Static Analysis,我有以下代码: const mapStateToFilterProps = (state:DataExplorerState, props) => ({ loading: state.loading, filters: state.filters }); const actionCreators: ActionCreators<string, Action> = { updateLoadState, updateFilters, updateChartData}; cons

我有以下代码:

const mapStateToFilterProps = (state:DataExplorerState, props) => ({ loading: state.loading, filters: state.filters });

const actionCreators: ActionCreators<string, Action> = { updateLoadState, updateFilters, updateChartData};

const mapDispatchToProps = (dispatch: Dispatch<Action>) => bindActionCreators(actionCreators, dispatch)

// TODO: Fix typing issue
export const FilterBoxConnect = connect(
    mapStateToFilterProps, 
    mapDispatchToProps
)(FilterBox)

TODO下面的代码表示它未被发现。我该怎么办呢?

问题可能已经解决了。我不知道,我没有测试它,但维护人员声称情况就是这样:,

我认为它被发现了,因为在0.85之前,连接不需要显式注释。0.85之后,流量将减小。基本上,如果我们在导出时不显式注释连接的组件,则流将报告隐式实例化的错误:

OP缺少类型批注。OP是在函数类型[1]中声明的类型参数,并且是隐式的 在调用connect[2]时实例化。 此外,我们现在可以通过提供类型参数来显式注释connect

import * as React from 'react'

type OwnProps = {|
  passthrough: string,
  forMapStateToProps: string
|}

type Props = {|
  ...OwnProps,
  fromMapStateToProps: string,
  dispatch1: () => void
|}

const MyComponent = (props: Props) => (
  <div onClick={props.dispatch1}>
    {props.passthrough}
    {props.fromMapStateToProps}
  </div>
)

export default connect<Props, OwnProps, _, _, _, _>(
  mapStateToProps,
  mapDispatchToProps
)(MyComponent)

我有一个更详细的指南。

我已经对它进行了测试,它似乎工作得很好。我很快就开始使用打字脚本,并鼓励大家也这样做。