This is the flatmap
:
const options = names.flatMap(
(object) => object.name " - " object.size "- " object.category
);
console.log(options)
:
If the object.category
is equals to S-XL
how can I not display its values? But if the object.category
is equals too ft
it will display the object.category
?Any help would be appreciated. Thank you
I'll be using the flatMap
here:
<Autocomplete
disablePortal
isOptionEqualToValue={(option, value) => option?.label === value?.label}
id="combo-box-demo"
options={options}
fullWidth
value={value}
onChange={onChange}
renderInput={(params) => <TextField {...params} label="Products" />}
required
/>
CodePudding user response:
const options = names.flatMap(
(object) =>
object.name
" - "
object.size
`${object.category == "ft" ? "- " object.category : ""}`
);