/
store.js
26 lines (23 loc) 路 826 Bytes
/
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
import { createStore, applyMiddleware, compose } from 'redux'
import thunk from 'redux-thunk'
import { routerMiddleware } from 'react-router-redux'
import { createHashHistory } from 'history'
import reducer, { initialState } from './reducers'
export const history = createHashHistory({
basname: '',
hashType: 'slash',
})
const middleware = routerMiddleware(history)
let middlewares
if (process.env.NODE_ENV === 'development') {
const DevTools = require('./devTools')
middlewares = compose(
applyMiddleware(thunk, middleware),
// Required! Enable Redux DevTools with the monitors you chose
DevTools.default.instrument()
)
} else {
middlewares = compose(applyMiddleware(thunk, middleware))
}
// Create store
export const store = createStore(reducer, initialState, middlewares)