selvi jp

selvi jp

  • 1.7k
  • 272
  • 13.6k

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)