报错情况如下:
如何解决以上错误呢?
1.安装redux-thunk模块:
这里我是用VScode进行安装,当然也可以根据个人习惯,比如使用WebStorm,powershell,cmd,git等进行安装。
2.在项目中src>index.js文件中引入中间件applyMiddleware,方法compose以及thunk对象:
3.将以上内容配置到createStore方法中:
4.处理好以上步骤,那么redux的异步操作就不会报错了。
redux执行异步操作时会报错:Actions must be plain objects. Use custom middleware for async actions.
最新推荐文章于 2023-09-15 11:24:12 发布