React Portal Playground

createPortal moves a child’s DOM out of its parent: does it escape overflow:hidden, and where do its events bubble, up the React tree or the DOM tree? React…

Why it matters

Almost every real app needs a portal for floating layers. Misreading its two trees breeds subtle bugs: a click in a modal that "leaks" to a parent’s handler, an addEventListener that never hears anything, focus that :focus-within does not see.

The key idea

A portal moves its DOM, not its place in the React tree

Common mistakes

Try it in this playground