UNPKG

@baseplate-dev/ui-components

Version:

Shared UI component library

15 lines 404 B
import { useEffect, useMemo, useRef } from 'react'; export function useEventCallback(fn) { const ref = useRef(fn); useEffect(() => { ref.current = fn; }, [fn]); return useMemo(() => { const { current } = ref; if (!current) { return; } return (...args) => current(...args); }, [ref]); } //# sourceMappingURL=use-event-callback.js.map