FitTrackee/mpwo_client/src/index.js

38 lines
1.0 KiB
JavaScript
Raw Normal View History

2017-12-17 14:02:41 +01:00
/* eslint-disable react/jsx-filename-extension */
import { createBrowserHistory } from 'history'
import React from 'react'
import ReactDOM from 'react-dom'
import { routerMiddleware } from 'react-router-redux'
import { applyMiddleware, createStore, compose } from 'redux'
import thunk from 'redux-thunk'
import App from './components/App'
import Root from './components/Root'
2017-12-17 14:02:41 +01:00
import registerServiceWorker from './registerServiceWorker'
import reducers from './reducers'
import { loadProfile } from './actions'
2017-12-17 14:02:41 +01:00
export const history = createBrowserHistory()
export const rootNode = document.getElementById('root')
export const store = createStore(
reducers,
window.__STATE__, // Server state
(window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose)(
applyMiddleware(routerMiddleware(history), thunk)
)
)
if (window.localStorage.getItem('authToken') !== null) {
store.dispatch(loadProfile())
}
2017-12-17 14:02:41 +01:00
ReactDOM.render(
<Root store={store} history={history}>
2017-12-17 14:02:41 +01:00
<App />
</Root>,
2017-12-17 14:02:41 +01:00
rootNode
)
registerServiceWorker()