useDebouncedCallback() has a slightly wrong type
VanTanev opened this issue · comments
Ivan Tanev commented
export interface DebouncedState<T extends (...args: any[]) => ReturnType<T>> extends ControlFunctions {
(...args: Parameters<T>): ReturnType<T>;
}
Should instead be:
export interface DebouncedState<T extends (...args: any[]) => ReturnType<T>> extends ControlFunctions {
(...args: Parameters<T>): ReturnType<T> | undefined;
}
The reason is that unless we're invoking on leading edge, the result
ref will not be set until the function has been debounced at least once.
Reproduction: https://codesandbox.io/s/use-debounced-callback-return-type-57jme
Nik commented
Published in v.6.0.1 Thanks for reporting!