Skip to content

Instantly share code, notes, and snippets.

@johnrhampton
Created June 21, 2016 12:40
Show Gist options
  • Save johnrhampton/e182bcfcfca14252c60495d7c0bbf4cd to your computer and use it in GitHub Desktop.
Save johnrhampton/e182bcfcfca14252c60495d7c0bbf4cd to your computer and use it in GitHub Desktop.
/common/stores/main.store.js
'use strict';
import {createStore, applyMiddleware, compose} from 'redux';
import thunkMiddleware from 'redux-thunk';
import createLogger from 'redux-logger';
import rootReducer from '../reducers';
import {ENV_TYPE} from '../constants/environment';
export let createStores = (initialState) => {
const store = createStore(
rootReducer,
initialState,
compose(
applyMiddleware(thunkMiddleware, createLogger()),
window.devToolsExtension ? window.devToolsExtension() : f => f
)
);
if (module.hot && ENV_TYPE === 'local') {
module.hot.accept('../reducers', () => {
const nextRootReducer = require('../reducers').default;
store.replaceReducer(nextRootReducer);
});
}
return store;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment