getModalPortal.tsx 357 B

1234567891011121314
  1. import memoize from 'lodash/memoize';
  2. const getModalPortal = memoize(() => {
  3. let portal = document.getElementById('modal-portal') as HTMLDivElement;
  4. if (!portal) {
  5. portal = document.createElement('div');
  6. portal.setAttribute('id', 'modal-portal');
  7. document.body.appendChild(portal);
  8. }
  9. return portal;
  10. });
  11. export default getModalPortal;