dubdiff/src/client/index.js

46 lines
1.0 KiB
JavaScript
Raw Normal View History

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'
// import createBrowserHistory from 'history/lib/createBrowserHistory'
import {Router, browserHistory} from 'react-router'
import thunk from 'redux-thunk'
import * as reducers from '../common/reducers'
import routes from '../common/routes'
import LocalStorage from './LocalStorage'
// initial state is rehydrated from the server
const initialState = JSON.parse(decodeURI(window.__INITIAL_STATE__))
// create the redux store
// initial state is retrieved from localStore
2016-11-23 22:58:48 +01:00
const store = Redux.createStore(
Redux.combineReducers(reducers),
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
)
function render () {
ReactDOM.render(
2016-11-23 22:58:48 +01:00
<Provider store={store}>
<LocalStorage >
<Router history={browserHistory}>
{routes}
2016-11-28 18:47:47 +01:00
</Router>
</LocalStorage>
2016-11-23 22:58:48 +01:00
</Provider>
, document.getElementById('root'))
}
render()