I am using react select in my react app same like below
when i use 'labelKey={'staffName'}' to get the key from api to search. so when I use like above its showing the output perfectly.
what I am trying to do is need to search another key lanId also. so I tried to add like this.
labelKey={'someid' || 'stafName'}
when adding 2 keys output is showing only for the first one. I need to find a way to add 2 keys for the filter search part . could anyone able to help me on this ??
<Select
name="selectStaf"
placeholder='Select Staf'
value={selectStaf}
onChange={this.handleChange}
options={stafDataList.stafsInfo}
multi={true}
labelKey={'someid' || 'stafName'}
valueKey={'stafId'}
isLoading={loadingee}
onInputKeyDown={(e)=>{this.filterStafApi(e)}}
/>
In JavaScript, the
||
operator would return the first item unless it is falsy (undefined
, ornull
, or0
or''
).You might want to try a string concatenation like this: