1

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)
Christophe
  • 27,383
  • 28
  • 97
  • 140

0 Answers0