Skip to content

Error: Uncaught [NotFoundError: The node to be removed is not a child of this node.] #820

Closed
@dremlin2000

Description

@dremlin2000

Summary:

This issue comes up when I run react testing library tests. It seems that the parent component removes react-modal I am assuming on unmount event what leads to Error: Uncaught [NotFoundError: The node to be removed is not a child of this node.]. . This issue is very similar to already raised one #769 but the corresponding PR #778 does not actually address the original issue.

I found code which causes this issue

const parent = getParentElement(this.props.parentSelector);
if (parent) {
parent.removeChild(this.node);
} else {
and fix should pretty simple like

    if (parent && parent.contains(this.node)) {
      parent.removeChild(this.node);
    }

I will appreciate if someone comes up with a workaround.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions