ReactReact Portals

Portals allow you to render components outside the main DOM hierarchy. Useful for modals, tooltips, etc., that need to break out of parent DOM containers.

import React from 'react';
import ReactDOM from 'react-dom';

function Modal({ children }) {
  return ReactDOM.createPortal(
    <div className=\"modal\">{children}</div>,
    document.getElementById('modal-root')
  );
}