Merge pull request #1490 from ghalestrilo/fix/mobile-crash-on-leave-preview

Fixes #1487
This commit is contained in:
Cassie Tarakajian 2020-07-06 15:20:39 -04:00 committed by GitHub
commit 97c3b3549c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -64,7 +64,8 @@ class PreviewFrame extends React.Component {
componentWillUnmount() { componentWillUnmount() {
window.removeEventListener('message', this.handleConsoleEvent); window.removeEventListener('message', this.handleConsoleEvent);
ReactDOM.unmountComponentAtNode(this.iframeElement.contentDocument.body); const iframeBody = this.iframeElement.contentDocument.body;
if (iframeBody) { ReactDOM.unmountComponentAtNode(iframeBody); }
} }
handleConsoleEvent(messageEvent) { handleConsoleEvent(messageEvent) {