我是 React 和 Redux 的新手,我正在尝试使用 React 和 Django 构建一个 webapp(身份验证系统)。 我正在按照 tutorial 来使用这个 github 目录 来做到这一点。 当我尝试从“redux-thunk”导入 Store.js 中的 thunk 时,它在 React App (localhost:3000) 的主页上返回以下错误: ./src/Store.js 中的错误 8:20-25 在“redux-thunk”中找不到导出“default”(作为“thunk”导入)(可能的导出:thunk、withExtraArgument)
我尝试过使用“{ thunk }”,这种方法在主React应用程序上给了我黑色页面(localhost:3000)。
代码: Store.js
import { legacy_createStore, applyMiddleware } from "redux";
import { composeWithDevTools } from "redux-devtools-extension";
import thunk from "redux-thunk";
import MainReducer from "./reducer/MainReducer";
const initialState = {}
const middleware = [thunk]
const Store = legacy_createStore(
MainReducer,
initialState,
composeWithDevTools(applyMiddleware(...middleware))
);
export default Store;
如果 thunk 导入成功,预计会出现 Redux 应用程序的主页,如 14:27 时间戳的video所示。
我刚刚解决了这个问题。因此,如果有人遇到同样的问题,请将程序放在这里。
从 'redux-thunk' 导入 { thunk }; 确实是正确的方法。主要问题是我的浏览器上没有安装“Redux DevTools”作为扩展。我安装了它并部分解决了问题。 然后,在 App.js 中,我错误地将“组件”而不是“组件”放在路由中,因此纠正它也有帮助。我还重新安装了开发中涉及的软件包。
简而言之,