I am trying to use AsyncSelect
from react-select
library.
I have enabled cacheOptions
option.
Using below mentioned steps I am seeing an issue with loadOptions
- Search for a string
test
- List of options gets displayed
Clear
the input field- Enter
same string
againtest
- Immediately displays
same list of options
loadOptions
fires an API with search inputtes
Clear
the input field- Enter
same string
againtest
- Immediately displays
same list of options
- loadOptions fires API with search input
te
.
I am not sure why loadOptions getting fired in this scenario if I am entering the same search string.
Here is the AsyncSelect
<AsyncSelect
classNamePrefix="select-item"
onChange={ onOptionSelect }
getOptionValue={ item => item.id }
placeholder="Search by Item"
formatOptionLabel={ company => <CompanyWithIcon Item={ Item } /> }
loadOptions={ loadOptions }
styles={ customStyles }
isSearchable
cacheOptions
isClearable
/>
Here is the loadOptions
function
const loadOptions = inputValue => searchItem(inputValue);
Can anybody please help?