FitTrackee/fittrackee_client_old/src/index.js

47 lines
1.3 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 { I18nextProvider } from 'react-i18next'
2017-12-17 14:02:41 +01:00
import ReactDOM from 'react-dom'
import { routerMiddleware } from 'connected-react-router'
import { applyMiddleware, compose, createStore } from 'redux'
2017-12-17 14:02:41 +01:00
import thunk from 'redux-thunk'
import i18n from './i18n'
2017-12-17 14:02:41 +01:00
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'
import { historyEnhancer } from './utils/history'
2017-12-17 14:02:41 +01:00
export const history = historyEnhancer(createBrowserHistory())
2017-12-17 14:02:41 +01:00
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}>
<I18nextProvider i18n={i18n}>
<App />
</I18nextProvider>
</Root>,
2017-12-17 14:02:41 +01:00
rootNode
)
registerServiceWorker()