ReactJs — React Portals
Portals allow you to render children into a DOM node outside of the parent component hierarchy. This is useful for modals, tooltips, and pop-ups.
import React from 'react';
import ReactDOM from 'react-dom';
function Modal({ children }) {
return ReactDOM.createPortal(
<div className="modal">{children}</div>,
document.getElementById('modal-root')
);
}
export default Modal;