简体   繁体   English

如何在Dropdown语义UI反应中更改状态

[英]How to change state in Dropdown semantic-ui-react

I'm trying to change state onChange in Dropdown Component 我正在尝试在下拉组件中更改状态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);
    });
  }

The state changes fine. 状态变化良好。 Problem is that Dropdown's value always returns to default 'Select Friend'. 问题是下拉列表的值始终返回默认的“选择朋友”。

How can I make Dropdown change it's state to selected item? 如何使Dropdown将其状态更改为所选项目?

The Dropdown component is missing a value prop. Dropdown组件缺少值属性。 The value prop controls the current value of Dropdown. 值prop控制着Dropdown的当前值。 Just add the prop value = {this.state.currantDomain_id} to it. 只需添加prop value = {this.state.currantDomain_id}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM