Home
← All questions

React Portals — use cases and event bubbling

MediumPremiumReact

Asked at Meta · Amazon · Uber

React interview practice: Explain Portals, when to use them, and how synthetic events propagate.

Answer

A Portal renders children into a DOM node outside the parent hierarchy (document.body, a modal root) while keeping them in the React tree for context and event delegation.

Use cases:

  • Modals, tooltips, dropdowns that must escape overflow: hidden or stacking contexts.
  • Toasts/notifications mounted at the app root.
  • Embedded widgets in legacy DOM containers.

Event bubbling: React events bubble through the React tree, not the DOM tree — a click inside a portal still triggers handlers on ancestors in JSX.

Premium question

Unlock the full model answer with Mentoxis Premium.

Unlock with Premium