I have a react-select component, I want to add a functionality such that as soon as somebody types something in the react-select, There should be a api request that would fetch the items related to that keyword entered, How can i do this
Question posted in Javascript
A very good W3school tutorial can be found here.
A very good W3school tutorial can be found here.
2
Answers
Well You can do this without any API call just use the filter method to filter your options
You should try looking into AsyncSelect from ‘react-select/async’
Then create a function in your component to load the options from your API which should accept an input string and a callback and should make the API call based on the input string. Something like this
Then in your componen pass your loadOptions function into the loadOptions prop