Complete Portal Creation
Fill in the Blank Medium
Question
Fill in the blank to render a modal into document.body.
Code
return ReactDOM._____(
<div className="modal">{children}</div>,
document.body
);
Hint
This method renders children into a DOM node outside the component tree.
Explanation
ReactDOM.createPortal renders children into a DOM node that exists outside the parent component's DOM hierarchy. It's commonly used for modals and tooltips that need to escape parent CSS constraints.
Related Resources
Related Lessons
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.