reactjs - 模块 '"<文件路径>/react-redux "' has no exported member ' Dispatch'

标签 reactjs typescript npm redux react-redux

我正在关注 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 版本也没有帮助。

最佳答案

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

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

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

关于reactjs - 模块 '"<文件路径>/react-redux "' has no exported member ' Dispatch',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56119468/

相关文章:

javascript - webpack 为什么要构建 global.js?

javascript - 如果操作为 true,则从 OnPress 更新状态

ios - 如何使用 React Native 重现 iOS 11 map Bottom Sheet

javascript - react .js : the most efficient way to pass a parameter to an event handler without bind() in a component

javascript - 是否可以使用构造函数作为 TypeScript 中另一个函数的参数类型?

javascript - 在 ionic3 中使用带有延迟加载的全局导航提供程序是一种不好的做法吗?

javascript - 如何从 GitHub 源构建 leaflet.markercluster.js?

javascript - ReactJS:我可以在单独的组件中分离一个改变状态的函数吗?

javascript - Ionic2 在 Provider 中使用 Ionic Storage

npm - 通过 package.json 将视觉样式应用到在 npm 脚本中使用的 echo 命令