Loading…
A short voice session: one question, one follow-up, then instant feedback — up to 5 minutes.
Portals move the DOM node elsewhere, but React events still propagate through the React component tree, so the portal's ancestors in React receive the event.
createPortal renders children into a different DOM container, which helps escape overflow: hidden and stacking-context problems for modals, tooltips and dropdowns. Logically, though, the portal content stays a child of the component that rendered it: it receives context and its React events bubble to its React parents, not its DOM parents. That is why a click inside the modal can reach an onClick on a wrapper in the component tree. Stop propagation inside the portal if needed, and remember to manage focus, Escape handling and aria attributes yourself for accessibility.