Combining debounced query with `isFetching`
Hi! I'm running into an issue that I'm not sure how to approach. It seems like I'm somewhat on the right track, but I'm a bit stumped on what to do to resolve this.
I have the following situation:
This nicely waits for quick changes to be done before calling a summary again. However, there is one problem related to stale data:
This loading spinner almost never shows up, because it doesn't consider the 800 ms of 'stale' data being displayed.
I need to somehow know that a debounce is currently happening OR that a fetch is pending.
Do you have suggestions or ideas on how to solve this properly? From searching the docs, it seems like there's no debounce for tanstack query OOTB.
2 Replies
eastern-cyan•7d ago
You could return a
isDebouncing
boolean from your useDebouncedValueDeep
I'd assume you set a timeout somewhere in that hook, when you set that timeout you could also set isDebouncing
to true
, then, when the setTimeout
finishes you'd set it to false
fair-roseOP•7d ago
yeah, I guess keeping that state myself will make more sense here. Thanks for the suggestion!