useDebounceCallback calls debounce twice #587
mariusGundersen
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is probably a bug, but the bug report form didn't fit my report, since I didn't have a test case:
The implementation of useDebounceCallback is defined as this:
Why is it using both
useMemo
anduseRef
/useEffect
? ThedebouncedFunc.current
value isn't returned, it's only used inuseUnmount
to cancel the scheduled debounce function. On the other hand, the result ofuseMemo
is returned, but it is not cancelled on unmount. The observable effect of this is that iffunc
was asetState
then it would call it after the component has unmounted.It seems like there are two implementions here when there should only be one. I guess the
useRef
/useEffect
implementation is more robust.Beta Was this translation helpful? Give feedback.
All reactions