reactjs - 连接 Redux devtools 和 Thunk 中间件到 store
问题描述
我正在尝试将 redux-devtools 连接到我的商店,但我不断收到以下错误:“看起来您正在将多个商店增强器传递给 createStore()。这是不支持的。相反,将它们组合成一个函数错误。 "
*使用 Thunk 作为中间件。
尝试使用增强器,但我仍然遇到不同的错误。
帮助将不胜感激。
这就是我的商店的样子:
import {createStore,applyMiddleware} from 'redux';
import thunk from 'redux-thunk'
const initialState={
bla:"",
bla:"",
bla:"",
}
const reducer = (state= initialState, action)=>{
bla bla bla..
actions...
}
const store= createStore(reducer,applyMiddleware(thunk))
export default store;
解决方案
从文档:
import { createStore, applyMiddleware, compose } from 'redux';
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(reducer, composeEnhancers(applyMiddleware(...middleware));
));
推荐阅读
- python-3.x - 如何在 chrome 中为 selenium 设置假音频路径?
- javascript - 在哪些情况下您会关心浏览器选择的方向?
- javascript - 用点后 2 位小数分割字符串
- sparql - 出现次数 SPARQL
- haskell - Profunctor 的哪些属性不能进入 Haskell/PureScript?
- html - 将“list-group”放在右侧,而“cards”在左侧,Bootstrap
- makefile - 更改项目目录后Makefile不起作用
- c++ - 如何解决 OJ 上的“运行时错误”
- ruby-on-rails - Bundler 尝试更新 rails 但其版本保持不变
- r - 使用 tidyverse 和 base R 删除列 - 区别