React Async Select loadoption有时无法加载该选项。在几个查询集合反应后,这是一个非常奇怪的现象。loadoptions未加载任何值,但我从日志中可以看到,结果正确地来自后端查询。我的代码库完全是最新的,请使用react-select新版本并使用
“反应选择”:“ ^ 2.1.1”
这是我的react-async select组件的前端代码。我确实在getOptions函数中使用了反跳,以减少后端搜索查询的数量。我猜这应该不会造成任何问题。我想补充一点,在这种情况下,我观察到的是,loadoptions serach指示器(...)也没有出现在这种现象中。
import React from 'react';
import AsyncSelect from 'react-select/lib/Async';
import Typography from '@material-ui/core/Typography';
import i18n from 'react-intl-universal';
const _ = require('lodash');
class SearchableSelect extends React.Component {
constructor(props) {
super(props);
this.state = {
inputValue: '',
searchApiUrl: props.searchApiUrl,
limit: props.limit,
selectedOption: this.props.defaultValue
};
this.getOptions = _.debounce(this.getOptions.bind(this), 500);
//this.getOptions = this.getOptions.bind(this);
this.handleChange = this.handleChange.bind(this);
this.noOptionsMessage = this.noOptionsMessage.bind(this);
this.handleInputChange = this.handleInputChange.bind(this);
}
handleChange(selectedOption) {
this.setState({
selectedOption: selectedOption
});
if (this.props.actionOnSelectedOption) {
// this is for …Run Code Online (Sandbox Code Playgroud)