From 36f2c169586ea30518639d7b1493e08e05befb73 Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Mon, 31 Oct 2016 15:45:50 -0700 Subject: [PATCH] Wrap root component in root.js not app.js so hot reloading can work React-hot-loader v3 requires all sub components to be required in a different file. --- lib/intermediate-representation-dir/app.js | 8 ++------ lib/intermediate-representation-dir/root.js | 5 ++++- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/intermediate-representation-dir/app.js b/lib/intermediate-representation-dir/app.js index 8691f60aef41c..53e69583beb36 100644 --- a/lib/intermediate-representation-dir/app.js +++ b/lib/intermediate-representation-dir/app.js @@ -10,11 +10,9 @@ const rootElement = document.getElementById(`react-mount`) let Root = require('./root') if (Root.default) { Root = Root.default } -// Let site, plugins wrap the site e.g. for Redux. -const WrappedRoot = apiRunner('wrapRootComponent', { Root: Root }, Root) ReactDOM.render( - + , rootElement ) @@ -23,11 +21,9 @@ if (module.hot) { module.hot.accept(`./root`, () => { let NextRoot = require('./root') if (NextRoot.default) { NextRoot = NextRoot.default } - // Let site, plugins wrap the site e.g. for Redux. - const WrappedRoot = apiRunner('wrapRootComponent', { Root: NextRoot }, NextRoot) ReactDOM.render( - + , rootElement ) diff --git a/lib/intermediate-representation-dir/root.js b/lib/intermediate-representation-dir/root.js index ee4cdf1dd6ab9..61b22d8cfbf86 100644 --- a/lib/intermediate-representation-dir/root.js +++ b/lib/intermediate-representation-dir/root.js @@ -30,4 +30,7 @@ const Root = () => ( /> ) -export default Root +// Let site, plugins wrap the site e.g. for Redux. +const WrappedRoot = apiRunner('wrapRootComponent', { Root: Root }, Root) + +export default WrappedRoot