[英]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.