semantic ui react dropdown - 更新选项并取消选择下拉列表
semantic ui react dropdown - updating the options and making the dropdown unselected
It seems very simple, but if the dropdown has an item selected and then I change the available options and that new set of options also happens to contain the previously selected item then that item will be automatically selected when options change.
我想要的是只要选项发生变化,下拉菜单就会显示其占位符值。
useEffect(() => {
setSelectedReport(undefined);
}, [availableReports]);
<Dropdown
placeholder="Select Report"
fluid
selection
onChange={(e, data) => handleSelectedReportChange(data)}
options={availableReports}
value={selectedReport.value }
></Dropdown>
是否可能需要以某种方式强制组件完全重新渲染,从而忘记之前的选项?
我犯了一个非常愚蠢的错误,我需要确保下拉选项的值 属性 在不同的选项集中是唯一的。
It seems very simple, but if the dropdown has an item selected and then I change the available options and that new set of options also happens to contain the previously selected item then that item will be automatically selected when options change.
我想要的是只要选项发生变化,下拉菜单就会显示其占位符值。
useEffect(() => {
setSelectedReport(undefined);
}, [availableReports]);
<Dropdown
placeholder="Select Report"
fluid
selection
onChange={(e, data) => handleSelectedReportChange(data)}
options={availableReports}
value={selectedReport.value }
></Dropdown>
是否可能需要以某种方式强制组件完全重新渲染,从而忘记之前的选项?
我犯了一个非常愚蠢的错误,我需要确保下拉选项的值 属性 在不同的选项集中是唯一的。