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

13 lines (10 loc) 409 B
import { useContext } from 'react'; import { PortalContext } from './PortalContext.mjs'; const usePortalContext = () => { const context = useContext(PortalContext); if (!context) throw new Error('PortalContext must be used within a PortalProvider'); return context; }; const usePortalAnchorRef = () => usePortalContext().portalAnchorRef; export { usePortalAnchorRef, usePortalContext };