UNPKG

@restart/hooks

Version:

A set of utility and general-purpose React hooks.

8 lines 272 B
import { useCallback } from 'react'; import useCommittedRef from './useCommittedRef'; export default function useEventCallback(fn) { const ref = useCommittedRef(fn); return useCallback(function (...args) { return ref.current && ref.current(...args); }, [ref]); }