New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What's the best way to wait for user to stop typing before performing fetch? #169
Comments
You probably want to implement debouncing. Have a look at this example. |
@AndrewNoh you can use react-debounce-input |
@nkbt @moroshko I tried but ran into an error :( Since, I've been using @nkbt's react-debounce-input elsewhere on my project, I decided to use it conjunction with react-autosuggest. Unfortunately, on clicking on an item, I get the following error:
The culprit seems to be the line here: https://github.com/moroshko/react-autosuggest/blob/master/src/Autosuggest.js#L241 if (focusInputOnSuggestionClick === true) {
this.input.focus(); Since both of you are on this thread about this very topic, I figure this might be the best place to ask :) |
@oyeanuj Could you provide a minimal Codepen/repo that demonstrates the issue? |
@moroshko Here you go: http://codepen.io/oyeanuj/pen/PbMbRe?editors=0010 (just minimally modified your codepen from above). And thank you for the quick reply! |
Autosuggest docs suggest that
If you could do |
@moroshko Thanks for digging in! I just tried
It would be cleaner to have a way to pass the |
You cannot really pass ref to the underlying element in React, unless it is
somehow renamed. I am not quite sure it is a good idea.
|
@nkbt Have a look at the example here. It's definitely possible to pass a Option 1 <DebounceInput inputRef={...} /> and you render Option 2 <DebounceInput inputProps={inputProps} /> where My personal preference would be option 2, but I don't particularly care as long as there is a way to provide a ref to the input element. Does this make sense? |
Wow, this was a long time ago. But, thanks all. I debounce all the things now. I like using lodash's debounce. Great for things like preventing users from spamming a button too. |
Closing for now. |
@moroshko getting this error |
No description provided.
The text was updated successfully, but these errors were encountered: