What are portals in React?

Portals allow rendering children into a DOM node outside the component’s parent hierarchy, useful for modals or tooltips.

ReactDOM.createPortal(<ModalContent />, document.getElementById("modal-root"));