UNPKG

@bothub-chat/ui

Version:

Bothub UI Components

2 lines (1 loc) 475 B
import{__rest as e}from"tslib";import{useState as t,useEffect as r}from"react";import l from"react-dom";import{PortalElement as o,portalId as n}from"./styled.js";const m=m=>{var{children:c}=m,i=e(m,["children"]);const[d,u]=t(null);return r(()=>{var e;void 0!==i.element?u(i.element):u(null!==(e=document.querySelector(String(o)))&&void 0!==e?e:document.getElementById(n))},[i.element]),null===d?null:l.createPortal(c,d)};export{m as Portal,o as PortalElement,n as portalId};