From 110a9b16bc25cc819bf412b360ea9ca1662ee8c7 Mon Sep 17 00:00:00 2001 From: Titouan Rigoudy Date: Sun, 10 Apr 2016 16:41:11 +0200 Subject: [PATCH] Fix configureStore to actually enable middleware. --- src/store/configureStore.dev.js | 33 ++++++++++++++++----------------- src/store/configureStore.js | 3 ++- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/store/configureStore.dev.js b/src/store/configureStore.dev.js index 3fa7e64..2dae7fe 100644 --- a/src/store/configureStore.dev.js +++ b/src/store/configureStore.dev.js @@ -2,26 +2,25 @@ //This boilerplate file is likely to be the same for each project that uses Redux. //With Redux, the actual stores are in /reducers. -import { createStore } from "redux"; +import { createStore, compose } from "redux"; import rootReducer from "../reducers"; -export default function configureStore(initialState, enhancer) { - let createStoreModded; - if (window.devToolsExtension) { //Enable Redux devtools if the extension is installed in developer's browser - createStoreModded = window.devToolsExtension()(createStore); - } else { - createStoreModded = createStore; - } +export default function configureStore(initialState, storeEnhancer) { + if (window.devToolsExtension) { + // Enable Redux devtools if the extension is installed in developer's + // browser. + storeEnhancer = compose(storeEnhancer, window.devToolsExtension()); + } - const store = createStoreModded(rootReducer, initialState, enhancer); + const store = createStore(rootReducer, initialState, storeEnhancer); - if (module.hot) { - // Enable Webpack hot module replacement for reducers - module.hot.accept('../reducers', () => { - const nextReducer = require('../reducers'); - store.replaceReducer(nextReducer); - }); - } + if (module.hot) { + // Enable Webpack hot module replacement for reducers + module.hot.accept('../reducers', () => { + const nextReducer = require('../reducers'); + store.replaceReducer(nextReducer); + }); + } - return store; + return store; } diff --git a/src/store/configureStore.js b/src/store/configureStore.js index ecde3a1..828ef8a 100644 --- a/src/store/configureStore.js +++ b/src/store/configureStore.js @@ -12,8 +12,9 @@ if (process.env.NODE_ENV === 'production') { export default () => { const logger = createLogger(); + const initialState = undefined; return configureStore( - undefined, + initialState, applyMiddleware(thunk, promise, logger) ); };