2016-11-23 22:58:48 +01:00
|
|
|
import React from 'react'
|
|
|
|
import ReactDOM from 'react-dom'
|
|
|
|
|
|
|
|
import * as Redux from 'redux'
|
|
|
|
|
|
|
|
import {Provider} from 'react-redux'
|
|
|
|
|
2016-12-15 01:06:14 +01:00
|
|
|
//import createBrowserHistory from 'history/lib/createBrowserHistory'
|
|
|
|
import {Router, Route, IndexRoute, Redirect, browserHistory } from 'react-router'
|
2016-12-04 04:14:15 +01:00
|
|
|
|
2016-12-14 19:02:27 +01:00
|
|
|
import thunk from 'redux-thunk'
|
|
|
|
|
2016-12-04 04:14:15 +01:00
|
|
|
import * as reducers from '../common/reducers'
|
|
|
|
import routes from '../common/routes'
|
2016-12-15 20:28:23 +01:00
|
|
|
import * as Actions from '../common/actions'
|
|
|
|
|
|
|
|
import LocalStorage from './LocalStorage'
|
2016-12-14 07:30:09 +01:00
|
|
|
|
2016-11-23 22:58:48 +01:00
|
|
|
|
|
|
|
|
2016-12-17 06:26:04 +01:00
|
|
|
//initial state is rehydrated from the server
|
2016-12-09 23:07:42 +01:00
|
|
|
const initialState = window.__INITIAL_STATE__
|
|
|
|
|
2016-11-23 22:58:48 +01:00
|
|
|
//create the redux store
|
|
|
|
//initial state is retrieved from localStore
|
|
|
|
const store = Redux.createStore(
|
|
|
|
Redux.combineReducers(reducers),
|
2016-12-09 23:07:42 +01:00
|
|
|
initialState,
|
2016-12-17 06:26:04 +01:00
|
|
|
Redux.compose(
|
|
|
|
Redux.applyMiddleware(thunk),
|
|
|
|
window.devToolsExtension ? window.devToolsExtension() : f => f
|
|
|
|
)
|
2016-11-23 22:58:48 +01:00
|
|
|
)
|
|
|
|
|
2016-12-09 23:07:42 +01:00
|
|
|
|
2016-12-15 20:28:23 +01:00
|
|
|
|
2016-11-23 22:58:48 +01:00
|
|
|
function render() {
|
|
|
|
ReactDOM.render(
|
|
|
|
<Provider store={store}>
|
2016-12-15 20:28:23 +01:00
|
|
|
<LocalStorage >
|
2016-12-15 01:06:14 +01:00
|
|
|
<Router history={browserHistory}>
|
2016-12-04 04:14:15 +01:00
|
|
|
{routes}
|
2016-11-28 18:47:47 +01:00
|
|
|
</Router>
|
2016-12-15 20:28:23 +01:00
|
|
|
</LocalStorage>
|
2016-11-23 22:58:48 +01:00
|
|
|
</Provider>
|
|
|
|
, document.getElementById('root'))
|
|
|
|
}
|
|
|
|
|
|
|
|
render()
|
|
|
|
|