0

I'm trying to change state onChange in Dropdown Component

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?

Arthur K.
  • 112
  • 12

1 Answers1

1

The Dropdown component is missing a value prop. The value prop controls the current value of Dropdown. Just add the prop value = {this.state.currantDomain_id} to it.

MEnf
  • 1,482
  • 1
  • 12
  • 18
  • Also, make sure your option prop contains an array of objects in which each object contains a value key. e.g. `[{key:'', text:'', value:''}, {key:'', text:'', value:''},]` – MEnf Aug 28 '17 at 14:55