Replies: 2 comments
-
Indeed, having built-in support for debouncing in AsyncSelect would be a very useful feature! Many applications would benefit from this approach, especially to reduce unnecessary requests to the server and improve the user experience. |
Beta Was this translation helpful? Give feedback.
-
Another aspect to consider about adding built-in debounce support. I think in most cases it would probably be preferable to show the loading state as soon as a user starts typing but before the debounce timer is set. This gives the user an indication that their input has been received and is being processed. If we add debounce logic outside of this component, which my team has managed to do, the loading state doesn't get set until the debounce timer has expired causing a delay in the appearance of the loading state. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I think it would be great to add built-in debouncing for the async select. I would imagine it to be a prop that would accept a number of milliseconds for the debounce. The function loadOptions would then be called only after the set time has elapsed from the last user input.
I know it is possible to implement debouncing using, for example, the
debounce-promise
orlodash
libraries as described here #3075, but to me this seems a bit too complex for something that many people would probably benefit from using to limit unnecessary requests to the server. I have tried to implement it myself using useDebounce hook, but I didn't manage to do it (probably because I'm a react beginner)Thank you for considering this request, and thanks again for your hard work on react-select!
Beta Was this translation helpful? Give feedback.
All reactions