Skip to content

Calling close method in React #576

@mihkeleidast

Description

@mihkeleidast

Calling the close method on an iframe inside a React component fails with an uncaught DOMException:

Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions