UNPKG

@winglet/react-utils

Version:

React utility library providing custom hooks, higher-order components (HOCs), and utility functions to enhance React application development with improved reusability and functionality

17 lines (14 loc) 436 B
import { memo, useEffect } from 'react'; import { usePortalContext } from './context/usePortalContext.mjs'; const Portal = memo(({ children }) => { const { register, unregister } = usePortalContext(); useEffect(() => { const id = register(children); return () => { if (id) unregister(id); }; }, [children, register, unregister]); return null; }); export { Portal };