我正在尝试AsyncSelect从react-select图书馆使用。
我已启用cacheOptions选项。
使用下面提到的步骤,我看到了一个问题loadOptions
- 搜索字符串
test - 显示选项列表
Clear输入字段same string再次输入test- 立即显示
same list of options loadOptions使用搜索输入触发 APItesClear输入字段same string再次输入test- 立即显示
same list of options - loadOptions 使用搜索输入触发 API
te。
如果我输入相同的搜索字符串,我不确定为什么 loadOptions 在这种情况下会被触发。
这里是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
/>
这是loadOptions功能
const loadOptions = inputValue => searchItem(inputValue);
有人可以帮忙吗?