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

Function WrapDom

packages/grapesjs-react/src/utils/react.tsx:7–25  ·  view source on GitHub ↗
(el: HTMLElement | string)

Source from the content-addressed store, hash-verified

5import { isString } from './dom';
6
7export const WrapDom = (el: HTMLElement | string) => {
8 return function WrapElement() {
9 const ref = useRef<HTMLDivElement>(null);
10
11 useEffect(() => {
12 const { current } = ref;
13
14 if (current) {
15 if (isString(el)) {
16 current.innerHTML = el;
17 } else {
18 current.appendChild(el);
19 }
20 }
21 }, [ref.current]);
22
23 return <div ref={ref} />;
24 };
25};
26
27export interface PortalContainerProps {
28 children: ReactNode;

Callers 1

toListenFunction · 0.90

Calls 1

isStringFunction · 0.90

Tested by

no test coverage detected