webscopeio / react-textarea-autocomplete

📝 React component implements configurable GitHub's like textarea autocomplete.
MIT License
451 stars 80 forks source link

Debounce dataProvider for remote data #96

Closed superandrew213 closed 5 years ago

superandrew213 commented 5 years ago

Performing server lookups on every letter change might not be necessary. Receiving the delayed results one after another doesn't look that nice either.

What do you think about adding an option to debounce dataProvider?

Another option would be to provide a results prop and a onTokenChange prop? This way we can have more control.

Or maybe I am missing something and you can already do this.

superandrew213 commented 5 years ago

I got it to work using debounce-promise. Lodash.debounce was not working properly.

jukben commented 5 years ago

Yeah! The data provider is able to eat Promise, so it should be fine to use whatever solution you might like.

anton6 commented 3 years ago

@superandrew213 can you please share a code snippet with the debounce-promise. In my case what seems to happen is it stacks all the calls to dataProvider and calls them all after the debounce period.

anton6 commented 3 years ago

The problem was on my end, I was playing with react-textarea-autocomplete inside of react-styleguidst code snippet which triggers re-render on every update.