UNPKG

lube-cra-seed

Version:

This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app).

51 lines (41 loc) 1.43 kB
import { applyMiddleware, compose, createStore } from 'redux' import createSagaMiddleware from 'redux-saga' import sagas from './sagas' import { makeRootReducer } from './reducers' export default (initialState = {}) => { // ====================================================== // Middleware Configuration // ====================================================== const sagaMiddleware = createSagaMiddleware() const middleware = [sagaMiddleware] // ====================================================== // Store Enhancers // ====================================================== const enhancers = [] if (process.env.NODE_ENV === 'development') { const devToolsExtension = window.devToolsExtension if (typeof devToolsExtension === 'function') { enhancers.push(devToolsExtension({actionsBlacklist: ['@@redux-form/CHANGE']})) } } // ====================================================== // Store Instantiation and HMR Setup // ====================================================== const store = createStore( makeRootReducer(), initialState, compose( applyMiddleware(...middleware), ...enhancers ) ) store.asyncReducers = {} sagaMiddleware.run(sagas) if (module.hot) { module.hot.accept('./reducers', () => { const reducers = require('./reducers').default store.replaceReducer(reducers) }) } return store }