mon-entreprise/source/entry.js

43 lines
1.1 KiB
JavaScript

import React from 'react'
import { render } from 'react-dom'
import { compose, createStore, applyMiddleware } from 'redux'
import App from './containers/App'
import reducers from './reducers'
import DevTools from './DevTools'
import { AppContainer } from 'react-hot-loader'
import debounceFormChangeActions from './debounceFormChangeActions'
import computeThemeColours from './components/themeColours'
import { getIframeOption, getUrl } from './utils'
let initialStore = {
iframe: getUrl().includes('iframe'),
themeColours: computeThemeColours(getIframeOption('couleur'))
}
let createStoreWithMiddleware = applyMiddleware(debounceFormChangeActions())(
createStore
)
let store = createStoreWithMiddleware(
reducers,
initialStore,
compose(DevTools.instrument())
)
let anchor = document.querySelector('#js')
render(<App store={store} />, anchor)
// Hot react component reloading. Unstable but helpful.
if (module.hot) {
module.hot.accept('./containers/App', () => {
render(
<AppContainer>
<App store={store} />
</AppContainer>,
anchor
)
})
}
export { anchor }