0

我正在尝试更改下拉组件中的 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);
    });
  }

状态变化很好。问题是下拉菜单的值总是返回到默认的“选择朋友”。

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

4

1 回答 1

1

Dropdown 组件缺少 value 道具。value 属性控制 Dropdown 的当前值。只需将道具添加value = {this.state.currantDomain_id}到它。

于 2017-08-28T13:42:09.910 回答