今天 webpack 打包的时候遇到问题:

It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function
const store = createStore(
  Reducer, /* reducer */
  window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__(), /* preloadedState */
  applyMiddleware(thunk) /* enhancer(middleware) */
);

看起来新版本又更新了方法, 以前 createStore 集成 redux-devtool 的时候提供 3 个参数, 现在需要将后面的 middleware 全部包裹起来:


import { createStore, compose, applyMiddleware } from 'redux';

const composeEnhancer = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

const store = createStore(
  Reducer, /* reducer */
  composeEnhancer(
    applyMiddleware(thunk), /* enhancer(middleware) */
  )
);
  • 文章标题: 《Redux-DevTools Error: It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function》
  • 发布日期: 2018-11-15
  • 文章分类: Tech
  • 相关标签: JS Redux