Use different key for searching instead of value or label in react-select in reactJS
You can use getOptionLabel
and getOptionValue
:
<Select
name="selectSubTag"
id="selectSubTag"
value={this.state.selectedFilter.subTag}
options={this.state.jobSubTags}
getOptionLabel ={(option)=>option.tab}
getOptionValue ={(option)=>option.tabValue}
onChange={this.setSubTag}
placeholder="Select Sub Tag"/>
By default the react-select
searches over value
and label
, but if you added additional keys it will also include them in the search, so just iterate over the array and append value
label
keys equal to the tab
key or the tabValue
key and it will search upon them all, but remember that for display, the react-select
displays the label
key content