mon-entreprise/source/entry.js

37 lines
946 B
JavaScript
Raw Normal View History

2016-06-29 10:27:04 +00:00
import React from 'react'
import { render } from 'react-dom'
import { compose, createStore } from 'redux'
2016-06-29 10:27:04 +00:00
import App from './containers/App'
import reducers from './reducers'
import DevTools from './DevTools'
import { AppContainer } from 'react-hot-loader'
import computeThemeColours from './components/themeColours'
2016-06-29 10:27:04 +00:00
let url = window.location.href.toString(),
urlColour = url.includes('couleur=')
let initialStore = {
iframe: url.includes('iframe'),
themeColours: computeThemeColours(
urlColour && url.split('couleur=')[1].split('&')[0]
)
}
2016-06-29 10:27:04 +00:00
let store = createStore(reducers, initialStore, compose(DevTools.instrument()))
2016-06-29 10:27:04 +00:00
let anchor = document.querySelector('#js')
render(<App store={store} />, anchor)
2016-06-29 10:27:04 +00:00
// Hot react component reloading. Unstable but helpful.
2016-06-29 10:27:04 +00:00
if (module.hot) {
module.hot.accept('./containers/App', () => {
render(
<AppContainer>
<App store={store} />
2016-06-29 10:27:04 +00:00
</AppContainer>,
anchor
)
})
}
export { anchor }