UNPKG

alistair

Version:
14 lines (10 loc) 325 B
import { useRef, useLayoutEffect, useCallback } from 'react'; // Copyright 2025 Alistair Smith https://github.com/alii/alistair function useEvent(fn) { const ref = useRef(fn); useLayoutEffect(() => { ref.current = fn; }, [fn]); return useCallback((...args) => ref.current(...args), []); } export { useEvent };