Using debounce on loadOptions doesn't always show results
See original GitHub issueWhen I use lodash’s debounce on my loadOptions
handler, typing doesn’t behave consistently (results are missing, spinner is showing indefinitely) for certain inputs.
When the debounce is removed (and requests are fired for every keystroke), options are consistently shown. I’ve also tried setting cache={false}
to no avail.
Sample here: https://codesandbox.io/s/xplr0lly8w
To see this weird behavior, type a few letters of a github username into the text input. Observe it not really-but-sort-of-working.
To see it working consistently, remove this.getUsers = _.debounce(this.getUsers, 250);
in the constructor.
This occurs on react-select 1.2.1. Let me know if you need any more info to repro.
Also just wanted to say you guys and gals are doing great work!
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (3 by maintainers)
I managed to find a way to avoid the weird behaviour, here is a sandbox.
I don’t know if this is the desired result, but I thought I would share it just in case.
I think you need to use the callback option instead of returning a promise if you use debounce.
I changed your example in this snippet and it now works: https://codesandbox.io/s/mm16n2x5k9