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
Uh oh!
There was an error while loading. Please reload this page.
-
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
useMemoanduseRef/useEffect? ThedebouncedFunc.currentvalue isn't returned, it's only used inuseUnmountto cancel the scheduled debounce function. On the other hand, the result ofuseMemois returned, but it is not cancelled on unmount. The observable effect of this is that iffuncwas asetStatethen 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/useEffectimplementation is more robust.Beta Was this translation helpful? Give feedback.
All reactions