configureStore.dev.js
871 Bytes
import { createStore, applyMiddleware, compose } from 'redux'
import createSagaMiddleware, { END } from 'redux-saga'
import rootReducer from '../reducers'
import logger from 'redux-logger'
export default function configureStore(initialState) {
const sagaMiddleware = createSagaMiddleware()
const enhancer = compose(
applyMiddleware(sagaMiddleware, logger),
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
)
const store = createStore(
rootReducer,
initialState,
enhancer
)
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('../reducers', () => {
const nextRootReducer = require('../reducers').default
store.replaceReducer(nextRootReducer)
})
}
store.runSaga = sagaMiddleware.run
store.close = () => store.dispatch(END)
return store
}