-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstore.js
40 lines (33 loc) · 1.09 KB
/
store.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { createStore, applyMiddleware, compose } from 'redux';
import Immutable from 'seamless-immutable';
import reduxThunk from 'redux-thunk';
import rootReducer from './reducers/index';
export function configureStore(initialState = {}) {
/* eslint-disable no-param-reassign */
if (!initialState.toJS) {
initialState = Immutable(initialState);
}
/* eslint-disable no-underscore-dangle */
const composeEnhancers
= typeof window === 'object'
&& window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
// Specify extension’s options like name, actionsBlacklist, actionsCreators, serialize...
}) : compose;
const store = createStore(
rootReducer(),
initialState,
composeEnhancers(applyMiddleware(reduxThunk)),
);
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('./reducers', () => {
const nextRootReducer = rootReducer;
store.replaceReducer(nextRootReducer);
});
}
return store;
}
export function withRedux(BaseComponent) {
return (configureStore)(BaseComponent);
}