accelerator-core
Version:
[](https://travis-ci.org/furkleindustries/accelerator-core)
35 lines (30 loc) • 815 B
text/typescript
import {
IState,
} from './IState';
import {
createStore as reduxCreateStore,
} from 'redux';
import {
rootReducer,
} from '../reducers/rootReducer';
declare const window: any;
export function createStore(prerenderedState?: IState) {
const store = reduxCreateStore(
rootReducer,
prerenderedState,
(
typeof window !== 'undefined' &&
window &&
window.__REDUX_DEVTOOLS_EXTENSION__ &&
window.__REDUX_DEVTOOLS_EXTENSION__()
),
);
if (process.env.NODE_ENV === 'development' && (module as any).hot) {
// Enable Webpack hot module replacement for reducers
(module as any).hot.accept('../reducers/rootReducer', () => {
const nextRootReducer = require('../reducers/rootReducer');
store.replaceReducer(nextRootReducer);
});
}
return store;
}