insomnia/app/redux/create.js
2016-04-22 23:16:23 -07:00

30 lines
679 B
JavaScript

import {createStore, applyMiddleware} from 'redux'
import thunkMiddleware from 'redux-thunk'
import createLogger from 'redux-logger'
import rootReducer from './reducer'
const loggerMiddleware = createLogger({
collapsed: true
});
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('./reducer', () => {
const nextReducer = require('./reducer').default;
store.replaceReducer(nextReducer);
})
}
return store
}