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'
|
2018-11-18 16:37:33 +01:00
|
|
|
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'
|
2017-12-17 14:33:04 +01:00
|
|
|
import Root from './components/Root'
|
2017-12-17 14:02:41 +01:00
|
|
|
import registerServiceWorker from './registerServiceWorker'
|
2018-11-18 16:37:33 +01:00
|
|
|
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()
|
|
|
|
|
2019-08-25 21:10:59 +02:00
|
|
|
history.listen(() => {
|
2019-08-28 15:35:22 +02:00
|
|
|
window.scrollTo(0, 0)
|
2019-08-25 21:10:59 +02:00
|
|
|
})
|
|
|
|
|
2017-12-17 14:02:41 +01:00
|
|
|
export const rootNode = document.getElementById('root')
|
|
|
|
|
|
|
|
export const store = createStore(
|
2018-11-18 16:37:33 +01:00
|
|
|
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) {
|
2017-12-25 17:45:28 +01:00
|
|
|
store.dispatch(loadProfile())
|
|
|
|
}
|
|
|
|
|
2017-12-17 14:02:41 +01:00
|
|
|
ReactDOM.render(
|
2017-12-17 14:33:04 +01:00
|
|
|
<Root store={store} history={history}>
|
2017-12-17 14:02:41 +01:00
|
|
|
<App />
|
2017-12-17 14:33:04 +01:00
|
|
|
</Root>,
|
2017-12-17 14:02:41 +01:00
|
|
|
rootNode
|
|
|
|
)
|
|
|
|
registerServiceWorker()
|