FitTrackee/fittrackee_client/src/index.js

42 lines
1.1 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 'connected-react-router'
2017-12-17 14:02:41 +01:00
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 createRootReducer from './reducers'
2018-04-29 17:18:16 +02:00
import { loadProfile } from './actions/user'
2017-12-17 14:02:41 +01:00
export const history = createBrowserHistory()
history.listen(() => {
2019-08-28 15:35:22 +02:00
window.scrollTo(0, 0)
})
2017-12-17 14:02:41 +01:00
export const rootNode = document.getElementById('root')
export const store = createStore(
createRootReducer(history),
2017-12-17 14:02:41 +01:00
window.__STATE__, // Server state
(window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose)(
applyMiddleware(routerMiddleware(history), thunk)
)
)
2017-12-25 20:11:10 +01:00
if (window.localStorage.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()