-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update compile-time error overlay to use react-error-overlay components
* Refactor react-error-overlay components to container and presentational components. * Make the compile-time error overlay a part of react-error-overlay package. * Use react-error-overlay as dependency in react-dev-utils to show compile-time errors.
- Loading branch information
Showing
21 changed files
with
444 additions
and
394 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
[ignore] | ||
.*/node_modules/eslint-plugin-jsx-a11y/.* | ||
|
||
[include] | ||
src/**/*.js | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
/* @flow */ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import CompileErrorContainer from './containers/CompileErrorContainer'; | ||
import { mountOverlayIframe } from './utils/dom/mountOverlayIframe'; | ||
|
||
let container: HTMLDivElement | null = null; | ||
let iframeReference: HTMLIFrameElement | null = null; | ||
|
||
function mount(callback) { | ||
iframeReference = mountOverlayIframe(containerDiv => { | ||
container = containerDiv; | ||
callback(); | ||
}); | ||
} | ||
|
||
function unmount() { | ||
if (iframeReference === null) { | ||
return; | ||
} | ||
ReactDOM.unmountComponentAtNode(container); | ||
window.document.body.removeChild(iframeReference); | ||
iframeReference = null; | ||
container = null; | ||
} | ||
|
||
function render(error: string) { | ||
ReactDOM.render(<CompileErrorContainer error={error} />, container); | ||
} | ||
|
||
function showCompileErrorOverlay(error: string) { | ||
if (container == null) { | ||
mount(() => render(error)); | ||
} else { | ||
render(error); | ||
} | ||
return unmount; | ||
} | ||
|
||
export { showCompileErrorOverlay }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.