Skip to content

Commit

Permalink
Improve interaction between compile and runtime overlays (#2219)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed May 18, 2017
1 parent 43b819c commit 6c8b18b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions packages/react-dev-utils/webpackHotDevClient.js
Expand Up @@ -38,7 +38,7 @@ function createOverlayIframe(onIframeLoad) {
iframe.style.width = '100vw';
iframe.style.height = '100vh';
iframe.style.border = 'none';
iframe.style.zIndex = 9999999999;
iframe.style.zIndex = 2147483647;
iframe.onload = onIframeLoad;
return iframe;
}
Expand Down Expand Up @@ -192,22 +192,24 @@ function clearOutdatedErrors() {
// Successful compilation.
function handleSuccess() {
clearOutdatedErrors();
destroyErrorOverlay();

var isHotUpdate = !isFirstCompilation;
isFirstCompilation = false;
hasCompileErrors = false;

// Attempt to apply hot updates or reload.
if (isHotUpdate) {
tryApplyUpdates();
tryApplyUpdates(function onHotUpdateSuccess() {
// Only destroy it when we're sure it's a hot update.
// Otherwise it would flicker right before the reload.
destroyErrorOverlay();
});
}
}

// Compilation with warnings (e.g. ESLint).
function handleWarnings(warnings) {
clearOutdatedErrors();
destroyErrorOverlay();

var isHotUpdate = !isFirstCompilation;
isFirstCompilation = false;
Expand All @@ -231,6 +233,9 @@ function handleWarnings(warnings) {
// Only print warnings if we aren't refreshing the page.
// Otherwise they'll disappear right away anyway.
printWarnings();
// Only destroy it when we're sure it's a hot update.
// Otherwise it would flicker right before the reload.
destroyErrorOverlay();
});
} else {
// Print initial warnings immediately.
Expand Down
2 changes: 1 addition & 1 deletion packages/react-error-overlay/src/styles.js
Expand Up @@ -15,7 +15,7 @@ const iframeStyle = {
width: '100%',
height: '100%',
border: 'none',
'z-index': 1337,
'z-index': 2147483647 - 1, // below the compile error overlay
};

const overlayStyle = {
Expand Down

0 comments on commit 6c8b18b

Please sign in to comment.