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

15 lines (12 loc) 385 B
import { useCallback } from 'react'; import { useReference } from './useReference.mjs'; const useHandle = (handler) => { const handelRef = useReference(handler); return useCallback((...args) => { if (typeof handelRef.current !== 'function') { return null; } return handelRef.current(...args); }, [handelRef]); }; export { useHandle };