davidjbradshaw / iframe-resizer-react

The official React interface for Iframe-Resizer

Home Page:https://iframe-resizer.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when iframe closes

pieshop opened this issue · comments

In my app when I switch from a page with an iFrame to a new page I am getting a console error

* Uncaught TypeError: Cannot read property 'id' of null
* at onClose (index.es.js:1488)
* at chkEvent (index.es.js:633)
* at closeIFrame (index.es.js:651)
* at eval (index.es.js:1062)
* at Array.forEach (<anonymous>)
* at eval (index.es.js:1060)
* at Array.forEach (<anonymous>)
* at MutationObserver.eval (index.es.js:1058)

The error is thrown here:
[iframeSizerReact][${iframeRef.current.id}] Close event ignored, to remove the iframe update your React component

iframeRef.current is null when this message is attempted.

Would you be able to make a simple test case for me to look at?

So I think this can be fixed by changing the line about from false, to !iframeRef.current,

Can you test this for me?

Sorry I haven't responded sooner David.

So I changed to:

warning_1(!iframeRef.current, "[iframeSizerReact][" + iframeRef.current.id + "] Close event ignored, to remove the iframe update your React component");

This is much better as it just throws a console warning:

"[iFrameSizer][Host page: iFrameResizer0] [Window resize] IFrame(iFrameResizer0) not found"

Fixed in v1.0.1

Hi,
This is still a bit annoying during development time.
image

As it still tries to get 'Id' from 'iframeRef.current' regardless if its null or not for the string interpolation.
Thanks.

@ymor, can you create another ticket for that issue please