Open oyeanuj opened 7 years ago
Hello @oyeanuj Thanks for checking this out and thanks for your questions. All your points are valid and should be addressed as it's a common way to want to use any kind of autocomplete.
There is an onChange
available for use which passes you the new value as you type, which then you can make an ajax call to get new data - then update the state of the <Autocomplete/>
data
property. For debounce
- I would probably add a debounce
method in componentWillMount
. I'd most likely pull in something like throttle-debounce
or react-throttle
to help with this. A threshold would be nice to set in this case.
For now, the data has to be a simple array of strings. I anticipated adding more complex data, if you can see in the propTypes I have:
data: React.PropTypes.arrayOf(React.PropTypes.oneOfType([ React.PropTypes.string, React.PropTypes.object ])),
Which either takes an array of strings or an array of objects - but this code isn't finished just yet.
I encourage people to help out and submit pull requests, so if you are up for the challenge on points 1 and/or 2 I will gladly write some tests around them and accept a pull request!
You can also always fork and extend this if you have very specific functionality.
Have a good one, Joe
Hi @JFusco, Firstly, thank you for putting out this component!
I was hoping to make use of it in my project, but in my usecase, the data for the autocomplete is coming from the server. So, I was wondering if this component would work well for that use-case?
I was thinking that I'll probably need to do the following -
onChange
although it would be nice to have an option to set a minimum threshold beforeonChange
is fired.onChange
is fired, make a call to the server.Based on that approach, I had the following questions -
Thank you!