securityos/node_modules/next/dist/esm/client/portal/index.js

19 lines
590 B
JavaScript
Raw Normal View History

2024-09-06 15:32:35 +00:00
import { useEffect, useState } from "react";
import { createPortal } from "react-dom";
export const Portal = (param)=>{
let { children, type } = param;
const [portalNode, setPortalNode] = useState(null);
useEffect(()=>{
const element = document.createElement(type);
document.body.appendChild(element);
setPortalNode(element);
return ()=>{
document.body.removeChild(element);
};
}, [
type
]);
return portalNode ? /*#__PURE__*/ createPortal(children, portalNode) : null;
};
//# sourceMappingURL=index.js.map