react-redux出现流量错误,如何解决?

时间:2018-10-26 16:15:50

标签: javascript reactjs react-redux static-typing

我不确定是否遗漏了一些东西,但是我开始尝试让流程更流畅,并且出现了我可以找出的错误。基本上,似乎认为连接没有返回React组件,并且抛出了此错误:

app/javascript/packs/components/better-nav/index.jsx
      37│     return (
      38│       <Provider store={store}>
      39│         <div className="nav">
      40│           <GetItems />
      42│         </div>
      43│       </Provider>

     flow-typed/npm/react-redux_v5.x.x.js
 [2] 164│     ST: $Subtype<{[_: $Keys<Com>]: any}>

     app/javascript/packs/components/better-nav/components/utils/get_items.jsx
 [1]  34│ const mapDispatchToProps = (dispatch: Dispatch): { FetchItemsData: Function } => ({
      35│   FetchItemsData() {
      36│     dispatch(FetchData());
      37│   },
      38│ });

组件代码:

export class GetItemsComponents extends Component<Props> {
  static propTypes = {
    FetchItemsData: PropTypes.func.isRequired,
  };

  componentDidMount() {
    const { FetchItemsData } = this.props;
    FetchItemsData();
  }

  render() {
    return <span />;
  }
}

const mapDispatchToProps = (dispatch: Dispatch): { FetchItemsData: Function } => ({
  FetchItemsData() {
    dispatch(FetchData());
  },
});

export default connect(
  null,
  mapDispatchToProps
)(GetItemsComponents);

0 个答案:

没有答案