insomnia/app/stores/configureStore.js

27 lines
727 B
JavaScript
Raw Normal View History

2016-03-16 05:49:42 +00:00
import { createStore, applyMiddleware } from 'redux'
import thunkMiddleware from 'redux-thunk'
import createLogger from 'redux-logger'
import rootReducer from '../reducers'
const loggerMiddleware = createLogger();
export default function configureStore (initialState) {
const store = createStore(
rootReducer,
initialState,
applyMiddleware(
thunkMiddleware,
loggerMiddleware
)
);
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('../reducers', () => {
const nextReducer = require('../reducers').default;
store.replaceReducer(nextReducer);
})
}
return store
}