2017-04-12 05:04:27 +00:00
|
|
|
import React from 'react'
|
|
|
|
import {render} from 'react-dom'
|
|
|
|
import {syncHistoryWithStore, routerMiddleware} from 'react-router-redux'
|
|
|
|
import {composeWithDevTools} from 'redux-devtools-extension'
|
|
|
|
import Perf from 'react-addons-perf'
|
|
|
|
import {createStore, applyMiddleware} from 'redux'
|
|
|
|
import thunk from 'redux-thunk'
|
|
|
|
import RootReducer from './reducers'
|
|
|
|
import {Root} from 'components'
|
|
|
|
import {Routing, history} from './routing'
|
2017-04-14 06:23:36 +00:00
|
|
|
import {createLogger} from 'redux-logger'
|
|
|
|
|
2017-04-12 05:04:27 +00:00
|
|
|
// application styles
|
|
|
|
import 'assets/styles/etherwallet-master.less'
|
|
|
|
|
|
|
|
|
|
|
|
const configureStore = () => {
|
2017-04-14 06:23:36 +00:00
|
|
|
let thunkApplied = applyMiddleware(thunk);
|
|
|
|
let store;
|
|
|
|
let middleware;
|
|
|
|
|
2017-04-12 05:04:27 +00:00
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
2017-04-14 06:23:36 +00:00
|
|
|
window.Perf = Perf;
|
|
|
|
thunkApplied = composeWithDevTools(thunkApplied);
|
|
|
|
const logger = createLogger({
|
|
|
|
collapsed: true
|
|
|
|
});
|
|
|
|
middleware = applyMiddleware(routerMiddleware(history), logger);
|
|
|
|
} else {
|
|
|
|
middleware = applyMiddleware(routerMiddleware(history));
|
2017-04-12 05:04:27 +00:00
|
|
|
}
|
2017-04-14 06:23:36 +00:00
|
|
|
|
|
|
|
store = createStore(RootReducer, thunkApplied, middleware);
|
|
|
|
|
2017-04-12 05:04:27 +00:00
|
|
|
return store
|
|
|
|
};
|
|
|
|
|
|
|
|
const renderRoot = (Root) => {
|
|
|
|
let store = configureStore();
|
|
|
|
let syncedHistory = syncHistoryWithStore(history, store);
|
|
|
|
render(
|
2017-04-14 06:23:36 +00:00
|
|
|
<Root key={Math.random()}
|
|
|
|
routes={Routing}
|
|
|
|
history={syncedHistory}
|
2017-04-12 05:04:27 +00:00
|
|
|
store={store}/>, document.getElementById('app'))
|
|
|
|
};
|
|
|
|
|
|
|
|
renderRoot(Root);
|
|
|
|
|
|
|
|
if (module.hot) {
|
|
|
|
module.hot.accept()
|
|
|
|
}
|