question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using debounce on loadOptions doesn't always show results

See original GitHub issue

When 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:closed
  • Created 5 years ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
JonathanWbncommented, Apr 13, 2018

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.

4reactions
JAndritschcommented, Mar 30, 2018

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-select debounced async call not displaying suggestions
It seems to work fine when I enter something in the searchbox for the first time (query is debounced and suggestions populated correctly),...
Read more >
Debouncing and Throttling Explained Through Examples
Having a debounced or throttled version of our function is ... But if the events are triggered with big gaps, the debouncing doesn't...
Read more >
Select | Quasar Framework
The QSelect Vue component has two types of selection - single or multiple. This component opens up a menu for the selection list...
Read more >
Create a Debounced Event Handler with the useMemo Hook
Our class-based component relies on instance variables to ensure it's only created once. this.amountChanged = debounce(this.props.
Read more >
react-select-async-paginate - npm
Start using react-select-async-paginate in your project by ... It should return next object: ... Debounce timeout for loadOptions calls.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found