我正在关注 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/