-
-
Notifications
You must be signed in to change notification settings - Fork 983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling close method in React #576
Comments
Have you tried this? |
Tried updating my componentDidMount/componentWillUnmount methods to the same as in https://github.com/zeroasterisk/react-iframe-resizer-super, on the other hand, does not try to call the close method at all when unmounting, resulting in "Iframe not found" warnings. |
I'm pretty sure when I tried the one I suggested a year ago it worked. Can you give the whole component ago? It get's the |
Unfortunately using that is not an option at all, since it hasn't been updated in a long time and still defines props via But I tried changing the way i get the reference, that did not work as well. |
Created a sandbox to demo the problem: https://codesandbox.io/s/23lxljzwoy |
Just had a look at the sandbox and pretty sure that never used to throw an error. It is clearly testing for the node before deleting it! In fact MDN even lists this example on how to safely remove a node from the DOM
I'm struggling to see how that differs from the line you highlighted.
I'd rather fix this properly, than add a flag as that risks creating a memory leak. However, currently I don't see how a node can not be a child of it's own parent! Welcome any ideas and insights you might have. |
A bit more digging and I came across this. It seems that their is a race condition in the browser, as the DOM is updated whilst we check it in the Update released as v3.6.1 |
@davidjbradshaw problem still exists with 3.6.1: https://codesandbox.io/s/l45zxp35rm in the repo i don't see any changes to source files. in the build folder the unminified files haven't been updated, too, and node points to the unminified files when importing. |
@davidjbradshaw any updates on this? |
I've just written my own React component for iframe-resizer https://github.com/davidjbradshaw/iframe-resizer-react |
Calling the close method on an iframe inside a React component fails with an uncaught DOMException:
This happens due to this line: https://github.com/davidjbradshaw/iframe-resizer/blob/master/src/iframeResizer.js#L552
The exception happes because in React, React itself handles the addition/removal of DOM elements and has already removed the element by the time iframe-resizer tries to to removeChild. But I would still like it to delete the reference to the iframe, otherwise i get a "Iframe not found" warning on every resize.
My react-iframe-resizer component: https://gist.github.com/risker/14360929f92c307feb06b146a8c379eb
The removal of the iframe element could be put behind an option flag, so the library would play better with React.
The text was updated successfully, but these errors were encountered: