我们正在使用带有Async选项的react-select。在ui,我们总是得到加载......'获取搜索字符串的结果之前的文本。如果我们删除setTimeout选项没有加载。那么我们如何在没有setTimeut的情况下渲染选项。
getOptions = (input, callback) => {
this.props.searchSymbols(input);
setTimeout(() => {
const results = [];
const { symbolList } = this.state;
if (symbolList.length > 0) {
Object.keys(symbolList).map(index => {
const symbolObj = {};
symbolObj.value = symbolList[index].symbolid;
symbolObj.instrumenttypename = symbolList[index].instrumenttypename;
symbolObj.exchangeid = symbolList[index].exchangeid;
symbolObj.label = symbolList[index].shortname;
results.push(symbolObj);
return results;
});
}
callback(null, {
options: results
});
}, 500);
};