diff --git a/src/NewWindow.js b/src/NewWindow.js index 19dbfb2..f918f6e 100644 --- a/src/NewWindow.js +++ b/src/NewWindow.js @@ -102,7 +102,7 @@ class NewWindow extends React.PureComponent { // Open a new window. this.window = window.open(url, name, toWindowFeatures(features)) - this.container = this.window.document.createElement('div') + this.container = this.window?.document.createElement('div') // When a new window use content from a cross-origin there's no way we can attach event // to it. Therefore, we need to detect in a interval when the new window was destroyed // or was closed. @@ -143,6 +143,8 @@ class NewWindow extends React.PureComponent { // Release anything bound to this component before the new window unload. this.window.addEventListener('beforeunload', () => this.release()) + + this.setState({ mounted: true }) } else { // Handle error on opening of new window. if (typeof onBlock === 'function') {