selvi jp

selvi jp

  • NA
  • 323
  • 77.1k

react-select cannot set id

Aug 17 2021 10:36 AM

i want to display name and store their id .but i can only pass name

dropdownhandleChange = (e) => {
this.setState({setSelectedValue:Array.isArray(e) ? e.map(x => x.value):null });
}
<Select 
defaultValue={defaultValueArr}
placeholder={"Select Mates"}
onChange={this.dropdownhandleChange}
options={Dropdownlist.map(e => ({ label: e.Name, value: e.Id}))}
isMulti
/>
var defaultValueArr = [];       
Details.map((Det)=>{  
Det.profile_name.split(',').map((e)=>{
defaultValueArr.push({label:e,value:e}); 
});   
});


Answers (21)