import { isNil } from "./assertions" ; import { useCallback } from "react" ; import { useCommittedRef } from "./useCommittedRef" ; export function useEventCallback < TCallback extends ( ... args : any [ ] ) => void > ( callback ) { const ref = useCommittedRef ( callback ) ; return useCallback ( ( ... args ) => { if ( ! isNil ( ref . current ) ) { ref . current ( ... args ) ; } } , [ ref ] ) as any ; }