【问题标题】:Module '"<file path>/react-redux"' has no exported member 'Dispatch'模块 '"<file path>/react-redux"' 没有导出的成员 'Dispatch'
【发布时间】:2019-09-30 20:01:35
【问题描述】:

我正在关注TypeScript-React-Starter tutorial,并将一个组件包装到一个容器中,Hello.tsx。第 4 行是

import {connect, Dispatch} from 'react-redux';

并在 Dispatch 上抛出以下错误:

Module '"../../node_modules/@types/react-redux"' has no exported member 'Dispatch'.


如何导入 Dispatch?

我需要更新一些东西吗? npm install 没有帮助,即使在更新到最新的 npm 版本之后也是如此。

【问题讨论】:

    标签: reactjs typescript npm redux react-redux


    【解决方案1】:
    Module '"../../node_modules/@types/react-redux"' has no exported member 'Dispatch'.  
    


    看起来 Dispatch 不再是 react-redux 的一部分;它是 redux 的一部分。使用

    导入调度
     import {Dispatch} from 'redux';
    

    保持联系

    import {connect} from 'react-redux';
    

    【讨论】:

      【解决方案2】:

      这真是一个突破性的变化。 Dispatch 是“redux”而不是“react-redux”的一部分。

      import { connect } from "react-redux";
      import { Dispatch } from "redux";
      

      欲了解更多信息,请访问TypeScript-React-Starter Issue

      【讨论】:

        猜你喜欢
        • 2021-12-19
        • 2022-01-18
        • 1970-01-01
        • 2022-01-17
        • 2022-01-19
        • 1970-01-01
        • 2022-01-16
        • 2018-10-09
        相关资源
        最近更新 更多