Support for throttling and debouncing when performing api call #1750
Replies: 5 comments
-
Both cases you are mentioning probably should have that information as part of the query key, which means in local state. There are good hooks for both throttling: https://github.com/jaredLunde/react-hook/tree/master/packages/throttle#readme and debouncing: https://usehooks.com/useDebounce/ |
Beta Was this translation helpful? Give feedback.
-
I'm also really interested in this. I implemented rudimentary throttling myself using the Any pointers on how to do better throttling would be appreciated. |
Beta Was this translation helpful? Give feedback.
-
+1 I'm implementing auto-save on mutations, (calling the mutation when user types), would be nice if one could pass throttle options directly to the hook instead of having to wrap it in a custom throttling logic. ideally one would pass the settings to the hook like so |
Beta Was this translation helpful? Give feedback.
-
For debounce, i suggest the React build-in hook: useDeferredValue |
Beta Was this translation helpful? Give feedback.
-
That would also be useful when using tanstack query outside of react e.g. for Angular. |
Beta Was this translation helpful? Give feedback.
-
I am wondering if we can have in-built support for throttling and denounce from the library. I have come across multiple cases where I needed it.
Beta Was this translation helpful? Give feedback.
All reactions