[英]React-select sometimes doesn't display the options in the dropdown menu on async search
這里很奇怪。 當使用 React-Select v1.0.0rc(盡管所有 v1.x 都會出現錯誤)在異步模式下使用它來搜索 API 時,有時選項不會顯示在下拉菜單中。 似乎沒有理由為什么會發生這種情況,但它發生在某些搜索查詢而不是其他搜索查詢中。
例如, coconut
有效但coconut oil
無效,即使兩者都返回相似的結果。
奇怪的是,使用 React chrome 開發人員工具我可以看到選項是在 Select 的狀態上設置的,但它們只是沒有出現。 另外,如果我點擊 react-select,然后點擊它,結果就會出現(在 firefox 和 chrome 中測試)。 這是我的代碼和一些截圖來說明
<Select.Async name={ this.generateName('ingredient_id')}
loadOptions={this.getIngredients}
className="admin-meal-ingredient-search-select"
autoload={false}
cache={false}
multi={false}
value={this.props.ingredient}
onChange={this.props.handleIngredientChange}
placeholder="Search for ingredient" />
出現
我正在使用"react-select": "^3.0.4",
並且不得不添加filterOption={false}
道具。
我找到了一個解決方案,那就是設置filterOptions= {false}
是的,它是filterOption ={false},輸入時要小心,這樣你就不會想知道為什么它不適合你:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.