es-toolkit
es-toolkit copied to clipboard
Why does a debounced function return void?
lodash, as well as es-toolkit/compat, do not change the return signature of a debounced function. Was the change in es-toolkit intentional?
It returns void and this makes it incompatible with lodash, currently i'm unable to upgrade.
In what cases do you need to use the returned value?
@dayongkr something like this:
useEffect(() => {
const debouncedRefetch = debounce(() => {
return refetch(
{ isMounted: true, search },
{
fetchPolicy: 'network-only',
}
)
}, 400)
const disposable = debouncedRefetch()
return () => disposable?.dispose()
}, [refetch, search])