【发布时间】:2021-03-17 16:20:08
【问题描述】:
我正在尝试以下拉列表的形式动态更新此数组,但它显示为空
const setCountries = async (e) =>{
if(e != null)
{
const countries = await survey.retrieveCountries(e);
let tmpArray = [] as any;
for (var i = 0; i < countries.length; i++) {
tmpArray.push(countries[i].name)
}
setCountryDropdown(tmpArray);
}
}
<Multiselect
options={countryDropdown} // Options to display in the dropdown
displayValue="Countries To Field" // Property name to display in the dropdown options
onSearch={(e) => setCountries(e)}
/>
【问题讨论】:
-
你用过图书馆吗?
-
这能回答你的问题吗? React does not re-render when state changes
-
演员阵容至少是可疑的。
retrieveCountries期待什么?该函数返回什么? -
在不知道
Multiselect是如何实现的或者您试图确认它没有改变的情况下,我认为这个问题需要更多的支持信息。
标签: reactjs