-
Notifications
You must be signed in to change notification settings - Fork 51
/
index.js
61 lines (53 loc) · 1.51 KB
/
index.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import 'babel-polyfill'
import 'es6-symbol/implement'
import React from 'react'
import { render } from 'react-dom'
import { createStore, applyMiddleware, compose } from 'redux'
import thunk from 'redux-thunk'
import createLogger from 'redux-logger'
import { history } from './history'
import { syncHistoryWithStore } from 'react-router-redux'
import WebFont from 'webfontloader'
import { apiMiddleware } from 'redux-api-middleware'
import rootReducer from './reducers'
import Root from './containers/Root'
import './styles/style.less'
WebFont.load({
google: {
families: [
'Source Sans Pro:200,400,600',
'Source Code Pro:400,600'
]
},
timeout: 2000
})
// const routerMiddleware = syncHistory(history)
const logger = createLogger({
predicate: (getState, action) =>
process.env && (process.env.NODE_ENV === 'development')
})
const finalCreateStore = compose(
applyMiddleware(
thunk,
apiMiddleware,
// routerMiddleware,
logger
)
)(createStore)
// Call and assign the store with no initial state
const store = ((initialState) => {
const store = finalCreateStore(rootReducer, initialState)
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('./reducers', () => {
const nextRootReducer = require('./reducers')
store.replaceReducer(nextRootReducer)
})
}
return store
})()
const enhancedHistory = syncHistoryWithStore(history, store)
render(
<Root store={store} history={enhancedHistory} />,
document.getElementById('root')
)