Portal Purpose
Question
What do React Portals do?
Hint
Portals escape parent styles (z-index, overflow).
Explanation
ReactDOM.createPortal(children, container) renders children into a DOM node outside the normal component DOM hierarchy. Use cases: modals, tooltips, dropdowns that need to escape parent CSS (overflow: hidden, z-index stacking context). The portal content still participates in React event bubbling — events from portal children bubble to React parents, not DOM parents. Portals are useful for UI overlays that must break out of clipping containers.
Related Resources
Related Lessons
- Portals
Learn portals.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.