diff --git a/source/containers/App.dev.js b/source/containers/App.dev.js index c380e4b1b..da2c13b46 100644 --- a/source/containers/App.dev.js +++ b/source/containers/App.dev.js @@ -1,19 +1,13 @@ -import React, { Component } from 'react' - -import { Provider } from 'react-redux' +import React from 'react' import DevTools from '../DevTools' +import { Provider } from 'react-redux' import Layout from './Layout' -export default class App extends Component { - render() { - const { store } = this.props - return ( - -
- - -
-
- ) - } -} +export default ({ store }) => ( + +
+ + +
+
+) diff --git a/source/containers/App.js b/source/containers/App.js deleted file mode 100644 index 2dbb70417..000000000 --- a/source/containers/App.js +++ /dev/null @@ -1,3 +0,0 @@ -if (process.env.NODE_ENV === 'production') - module.exports = require('./App.prod') -else module.exports = require('./App.dev') diff --git a/source/containers/App.prod.js b/source/containers/App.prod.js deleted file mode 100644 index 39706a209..000000000 --- a/source/containers/App.prod.js +++ /dev/null @@ -1,18 +0,0 @@ -// App.dev without the redux DevTools -import React, { Component } from 'react' - -import { Provider } from 'react-redux' -import Layout from './Layout' - -export default class App extends Component { - render() { - const { store } = this.props - return ( - -
- -
-
- ) - } -} diff --git a/source/containers/Layout.css b/source/containers/Layout.css index a07aacf0e..458a658c3 100644 --- a/source/containers/Layout.css +++ b/source/containers/Layout.css @@ -10,7 +10,7 @@ body { background: white; } #js, -#js > div { +#dev { height: 100%; } diff --git a/source/entry.dev.js b/source/entry.dev.js new file mode 100644 index 000000000..4b3f03b57 --- /dev/null +++ b/source/entry.dev.js @@ -0,0 +1,40 @@ +import React from 'react' +import { render } from 'react-dom' +import { compose, createStore, applyMiddleware } from 'redux' +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' + +import App from './containers/App.dev' + +let initialStore = { + iframe: getUrl().includes('iframe'), + themeColours: computeThemeColours(getIframeOption('couleur')) +} + +let enhancer = compose( + applyMiddleware(debounceFormChangeActions()), + DevTools.instrument() +) + +let store = createStore(reducers, initialStore, enhancer) +let anchor = document.querySelector('#js') + +render(, anchor) + +// Hot react component reloading. Unstable but helpful. +if (module.hot) { + module.hot.accept('./containers/App.dev', () => { + render( + + + , + anchor + ) + }) +} + +export { anchor } diff --git a/source/entry.js b/source/entry.js index f425367a1..7775af8af 100644 --- a/source/entry.js +++ b/source/entry.js @@ -1,42 +1,3 @@ -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(, anchor) - -// Hot react component reloading. Unstable but helpful. -if (module.hot) { - module.hot.accept('./containers/App', () => { - render( - - - , - anchor - ) - }) -} - -export { anchor } +if (process.env.NODE_ENV === 'production') + module.exports = require('./entry.prod') +else module.exports = require('./entry.dev') diff --git a/source/entry.prod.js b/source/entry.prod.js new file mode 100644 index 000000000..abd42a38a --- /dev/null +++ b/source/entry.prod.js @@ -0,0 +1,28 @@ +import React from 'react' +import { render } from 'react-dom' +import { compose, createStore, applyMiddleware } from 'redux' +import reducers from './reducers' +import debounceFormChangeActions from './debounceFormChangeActions' +import computeThemeColours from './components/themeColours' +import { getIframeOption, getUrl } from './utils' +import { Provider } from 'react-redux' +import Layout from './containers/Layout' + +let initialStore = { + iframe: getUrl().includes('iframe'), + themeColours: computeThemeColours(getIframeOption('couleur')) +} + +let enhancer = compose(applyMiddleware(debounceFormChangeActions())) + +let store = createStore(reducers, initialStore, enhancer) +let anchor = document.querySelector('#js') + +render( + + + , + anchor +) + +export { anchor }