From 6a1232a2583626f791a3152548c1190127c2d9c2 Mon Sep 17 00:00:00 2001 From: Brandon Pereira Date: Wed, 30 Oct 2019 16:56:33 -0600 Subject: [PATCH] fix(track-trail-updates): added ability to turn off trailing updates warns --- README.md | 5 +++++ src/hot.dev.js | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 70e9f6855..f87233d96 100644 --- a/README.md +++ b/README.md @@ -427,7 +427,9 @@ export default hot(Hello); // <-- module will reload itself Wrapping this root component with `hot()` will ensure that it is hot reloaded correctly. ### Out-of-bound warning + You may see the following warning when code-split components are updated: + ```console React-Hot-Loader: some components were updated out-of-bound. Updating your app to reconcile the changes. ``` @@ -447,6 +449,9 @@ in the configuration or useage of `react-hot-loader`. If the tail update detection is not something you want or need, you can disable this behavior by setting `setConfig({ trackTailUpdates:false })`. +Alternatively, if you want trail detection but don't want the logging, you can pass `setConfig({ trackTailUpdates:false })`. +This will keep it enabled but suppress the warnings. + ### Checking Element `type`s Because React Hot Loader creates proxied versions of your components, comparing diff --git a/src/hot.dev.js b/src/hot.dev.js index 016b0f9fe..37163dd73 100644 --- a/src/hot.dev.js +++ b/src/hot.dev.js @@ -66,9 +66,12 @@ const makeHotExport = (sourceModule, moduleId) => { // we know that some components were updated, but not tracking which ones // even if their updates might be incorporated automatically (like lazy) // we dont know which one should be tracked, and which updates are important - console.warn( - 'React-Hot-Loader: some components were updated out-of-bound. Updating your app to reconcile the changes.', - ); + if (typeof configuration.trackTailUpdates === 'boolean' && configuration.trackTailUpdates) { + // Disable logging because user passed 'true'... they are aware they should be tracked. + console.warn( + 'React-Hot-Loader: some components were updated out-of-bound. Updating your app to reconcile the changes.', + ); + } deepUpdate(); } else if (++runLimit < 5) { checkTailUpdates();