From acd349e35a2f7c12fc5cfa4610c60220fcd230ab Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Fri, 21 Jun 2019 05:58:57 -0700 Subject: [PATCH] Don't show "Hot Reloading" banner on first load Summary: D10527979 made the "update" message sequence part of initial connection signals. But the HMR client uses this sequence as a signal to show "Hot Reloading..." bar. As a result, we were showing it on every initial load when Hot Reloading is on. This is very confusing. As a simple fix, I now send an explicit message to mark the end of the first load. I could infer that by first update message but figured this is more explicit and less likely to break. Until we receive `connection-done`, we now don't attempt to show the "Hot Reloading..." bar. Reviewed By: rubennorte Differential Revision: D15936085 fbshipit-source-id: b18b6aceea6c47d919b4265e58b21fc44f77b0b3 --- Libraries/Utilities/HMRClient.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Libraries/Utilities/HMRClient.js b/Libraries/Utilities/HMRClient.js index f901778b659..4c275c98b40 100644 --- a/Libraries/Utilities/HMRClient.js +++ b/Libraries/Utilities/HMRClient.js @@ -69,8 +69,16 @@ Error: ${e.message}`; throw new Error(error); }); + let enableLoadingView = false; + hmrClient.on('connection-done', () => { + // Don't show the loading view during the initial update. + enableLoadingView = true; + }); + hmrClient.on('update-start', () => { - HMRLoadingView.showMessage('Hot Reloading...'); + if (enableLoadingView) { + HMRLoadingView.showMessage('Hot Reloading...'); + } }); hmrClient.on('update', () => { @@ -90,7 +98,9 @@ Error: ${e.message}`; }); hmrClient.on('update-done', () => { - HMRLoadingView.hide(); + if (enableLoadingView) { + HMRLoadingView.hide(); + } }); hmrClient.on('error', data => {