dubdiff/src/client/index.js

50 lines
1.1 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, Route, IndexRoute, Redirect, browserHistory } from 'react-router'
import thunk from 'redux-thunk'
import * as reducers from '../common/reducers'
import routes from '../common/routes'
import * as Actions from '../common/actions'
import LocalStorage from './LocalStorage'
2016-11-23 22:58:48 +01:00
2016-12-17 06:26:04 +01:00
//initial state is rehydrated from the server
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),
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-11-23 22:58:48 +01:00
function render() {
ReactDOM.render(
<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()