Debouncing support
See original GitHub issueHi there, I was wondering there is a way to “debounce” async option loading with react-select. Currently, I’m seeing queries like this:
I would like react-select to only query after a 250ms typing pause. What do I need to do to make react-select do this? I have tried wrapping my function in a setTimeout
, but that does not appear to do anything:
taxons (input, callback) {
setTimeout(function () {
$.ajax({
url: '/api/v2/taxons/search',
dataType: 'json',
cache: false,
data: { name: input },
success: function (response) {
var options = response.data.map(function(taxon, index) {
return (
{ value: taxon.id, label: taxon.attributes.tree_name }
);
});
callback(null, {
options: options
})
}
})
}, 250)
}
Issue Analytics
- State:
- Created 8 years ago
- Reactions:14
- Comments:44 (5 by maintainers)
Top Results From Across the Web
Contact - DeBounce
To open a support ticket, please send an email to support@debounce.io and our staff will respond to you shortly. Typically, messages will be...
Read more >What is debouncing? – TechTarget Definition
Debouncing is removing unwanted input noise from buttons, switches or other user input. Debouncing prevents extra activations or slow functions from ...
Read more >Debouncing via Software - Digilent Reference
Software debouncing is accomplished by taking multiple samples of the input signal and determining whether to assert an output signal (the debounced version...
Read more >Definition of Debounce - Analog Devices
A debouncing circuit removes the resulting ripple signal, and provides a clean transition at its output. Synonyms. Debounced. Find a term alphabetically: Select ......
Read more >A Guide to Debouncing - Oregon State University
Change the two hex constants to accommodate different bounce times and timer rates. // Service routine called by a timer interrupt bool_t DebounceSwitch2()....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A built-in
debounce
prop on theAsync
component would be a very welcome change.@grandmore I’ve got debouncing working. The key is to make sure that lodash’s
debounce
method is evaluated exactly once.Suppose you have a function
fetch
that retrieves the options for you and returns aPromise
. You can then create a debounced version of this function like:This
debouncedFetch
function can then be passed to theSelect.Async
component:Note that you cannot inline the
debouncedFetch
function in the render function of your component. If you do this, lodash’sdebounce
would be called whenever the component is rerendered. This breaks thedebounce
function.Hope this helps.