forked from paralect/react-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstore.js
More file actions
30 lines (24 loc) · 915 Bytes
/
store.js
File metadata and controls
30 lines (24 loc) · 915 Bytes
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
// @flow
import { createStore, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import { connectRouter, routerMiddleware } from 'connected-react-router';
import type { BrowserHistory } from 'history/createBrowserHistory';
import reducer from './reducer';
import type { StoreType, StateType } from './types';
const configureStore = (initialState: StateType, history: BrowserHistory): StoreType => {
const store: StoreType = createStore(
connectRouter(history)(reducer),
initialState,
compose(
applyMiddleware(routerMiddleware(history), thunk),
window.devToolsExtension ? window.devToolsExtension() : f => f, // eslint-disable-line
),
);
if (module.hot) {
module.hot.accept('./reducer', () => {
store.replaceReducer(connectRouter(history)(reducer));
});
}
return store;
};
export default configureStore;