Function
WrapDom
(el: HTMLElement | string)
Source from the content-addressed store, hash-verified
| 5 | import { isString } from './dom'; |
| 6 | |
| 7 | export 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 | |
| 27 | export interface PortalContainerProps { |
| 28 | children: ReactNode; |
Tested by
no test coverage detected