What happens to Portal child when container or its content is removed?

228 Views Asked by At

I plan to use React Portals for a solution I am building, and I am trying to understand what happens to the child when the container or its content is removed.

My code:

ReactDOM.createPortal(child, container)

Where container is a HTML element.

What is then going to happen to child in the following situations?

Case 1: container is removed from the DOM:

container.remove()

container.parentElement.removeChild(container)

Case 2: container content is unmounted

ReactDom.unmountComponentAtNode(container)
0

There are 0 best solutions below