import { useRef } from "react" ; export function useEventCallback < T > ( handler ? ) { const callbackRef = useRef ( handler ) ; const fn = useRef ( ( value ) => { callbackRef . current && callbackRef . current ( value ) ; } ) ; callbackRef . current = handler ; return fn . current ; }