如何在 Dropdown semantic-ui-react 中更改状态

How to change state in Dropdown semantic-ui-react

我正在尝试更改下拉组件中的 onChange 状态

const DropdownDomainSelection = () => (
      <Dropdown placeholder='Select Friend' selection options={domainsList} onChange={this.handleDomainsSelectChange} />
    )



handleDomainsSelectChange = (e, data) => {
    this.setState({
      currantDomain_id: data.value,
      currantWidget_id: "null",
    }, () => {
      console.log('this.state.currantDomain_id',this.state.currantDomain_id);
    });
  }

状态变好了。 问题是 Dropdown 的值总是 returns 到默认值 'Select Friend'。

如何让下拉菜单将其状态更改为所选项目?

Dropdown 组件缺少 value 属性。 value 属性控制 Dropdown 的当前值。只需添加属性 value = {this.state.currantDomain_id} 即可。