2017-12-17 14:02:41 +01:00
|
|
|
/* eslint-disable react/jsx-filename-extension */
|
|
|
|
import { createBrowserHistory } from 'history'
|
|
|
|
import React from 'react'
|
2019-09-08 11:17:02 +02:00
|
|
|
import { I18nextProvider } from 'react-i18next'
|
2017-12-17 14:02:41 +01:00
|
|
|
import ReactDOM from 'react-dom'
|
2018-11-18 16:37:33 +01:00
|
|
|
import { routerMiddleware } from 'connected-react-router'
|
2019-09-08 11:17:02 +02:00
|
|
|
import { applyMiddleware, compose, createStore } from 'redux'
|
2017-12-17 14:02:41 +01:00
|
|
|
import thunk from 'redux-thunk'
|
|
|
|
|
2019-09-08 11:17:02 +02:00
|
|
|
import i18n from './i18n'
|
2017-12-17 14:02:41 +01:00
|
|
|
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'
|
2020-01-31 12:46:38 +01:00
|
|
|
import { historyEnhancer } from './utils/history'
|
2017-12-17 14:02:41 +01:00
|
|
|
|
2020-01-31 12:46:38 +01:00
|
|
|
export const history = historyEnhancer(createBrowserHistory())
|
2017-12-17 14:02:41 +01:00
|
|
|
|
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}>
|
2019-09-08 11:17:02 +02:00
|
|
|
<I18nextProvider i18n={i18n}>
|
|
|
|
<App />
|
|
|
|
</I18nextProvider>
|
2017-12-17 14:33:04 +01:00
|
|
|
</Root>,
|
2017-12-17 14:02:41 +01:00
|
|
|
rootNode
|
|
|
|
)
|
|
|
|
registerServiceWorker()
|