-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigureStore.js
More file actions
29 lines (23 loc) · 878 Bytes
/
configureStore.js
File metadata and controls
29 lines (23 loc) · 878 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
import { createBrowserHistory } from 'history'
import { applyMiddleware, compose, createStore } from 'redux'
import { routerMiddleware } from 'react-router-dom'
import createSagaMiddleware from 'redux-saga'
import rootSaga from './sagas'
const sagaMiddleware = createSagaMiddleware()
export default function configureStore(initialState, rootReducer, history) {
let ENV = process.env.NODE_ENV
let composeEnhancers = compose
if (ENV !== 'production') {
const composeWithDevToolsExtension = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
if (typeof composeWithDevToolsExtension === 'function') {
composeEnhancers = composeWithDevToolsExtension
}
}
const store = createStore(
rootReducer, // root reducer with router state
initialState,
composeEnhancers(applyMiddleware(sagaMiddleware))
)
sagaMiddleware.run(rootSaga)
return store
}