MCPcopy Create free account
hub / github.com/GrapesJS/react / portalContainer

Function portalContainer

packages/grapesjs-react/src/utils/react.tsx:35–53  ·  view source on GitHub ↗
(el?: HTMLElement)

Source from the content-addressed store, hash-verified

33const elContainerMap = new WeakMap<HTMLElement, PortalContainerResult>();
34
35export function portalContainer(el?: HTMLElement): PortalContainerResult {
36 if (!el) {
37 return () => <></>;
38 }
39
40 const prevResult = elContainerMap.get(el);
41
42 if (prevResult) {
43 return prevResult;
44 }
45
46 const result = function Container({ children }: PortalContainerProps) {
47 return createPortal(createElement('div', null, children), el);
48 };
49
50 elContainerMap.set(el, result);
51
52 return result;
53}

Callers 6

upFunction · 0.90
upFunction · 0.90
toListenFunction · 0.90
upFunction · 0.90
toListenFunction · 0.90
upFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected