import { useDebouncedCallback as useThirdPartyDebouncedCallback } from "use-debounce" ; export function useDebouncedCallback < T extends ( ... args : any [ ] ) => ReturnType < T > > ( func , wait ? ) { const debounced = useThirdPartyDebouncedCallback ( func , wait , { leading : true } ) ; return debounced ; }