The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Rocket.Chat/client/components/ModalPortal.tsx

22 lines
572 B

import { FunctionComponent, memo, useState } from 'react';
import { createPortal } from 'react-dom';
const getModalRoot = (): Element => {
const modalRoot = document.getElementById('modal-root');
if (modalRoot) {
return modalRoot;
}
const newElement = document.createElement('div');
newElement.id = 'modal-root';
document.body.appendChild(newElement);
return newElement;
};
const ModalPortal: FunctionComponent = ({ children }) => {
const [modalRoot] = useState(getModalRoot);
return createPortal(children, modalRoot);
};
export default memo(ModalPortal);