Unhandled Rejection (NotFoundError): Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.
See original GitHub issueI have a component
<ComponentWithVideo />
that contains a list of tracks that are being rendered in a single <video/>
element.
That I rendered with <InPortal />
and displayed to <OutPortal />
This error occurs when I add another track and <ComponentWithVideo(s) />
re-renders.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Uncaught NotFoundError: Failed to execute 'insertBefore' on ...
I'm getting this error message: Uncaught NotFoundError: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be ......
Read more >Failed to execute 'insertBefore' on 'Node': The node ... - GitHub
Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this...
Read more >Failed to execute 'insertBefore' on 'Node' - Vue Forum
Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this...
Read more >error domexception: failed to execute 'insertbefore' on 'node'
React NotFoundError: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child...
Read more >VIBE BP 1.4.6 and console errors - wplms
DOMException: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That would work, and it’s a nice quick workaround you can use to fix this today.
It does affect the DOM structure though in a way that could affect styles (e.g. direct descendent selectors) which I’d like to avoid.
Using an empty text node doesn’t have that problem, and should work equally well as a proper fix, so while an extra div is good as a quick workaround, I’d like to avoid implementing that as the real solution.
Oooh, that’s really interesting, and yes that’s a complicated case that’s not handled well right now.
Any idea what the actual DOM transformations React is doing there are? The
insertBefore
in the previous case made sense, and seemed easy enough to handle, but it sounds like this is doing something different.In the meantime, you can probably handle this (and many other similar cases) by using
key
to force React to re-render the OutPortal during this update, instead of moving it. That way, React will first callcomponentWillUnmount
on the OutPortal (triggering the logic here that resets the placeholders), then it will mutate the DOM with placeholders everywhere as it expects, then it will mount a new OutPortal, and React-Reverse-Portal can then kick in and put the portal node content back. Since the actual DOM content lives inside your portalNode, making the OutPortal effectively stateless, that should be very cheap and totally invisible as a user.