I am trying to filter an array of objects based on the values selected in a multiselect element in React native
If I have the following array of data:
data = [
{"_id": "01", "brand": "1", "size": "20"},
{"_id": "02", "brand": "2", "size": "21"},
{"_id": "03", "brand": "1", "size": "19"},
{"_id": "04", "brand": "3", "size": "21"},
{"_id": "05", "brand": "1", "size": "20"},
{"_id": "06", "brand": "2", "size": "20"},
{"_id": "07", "brand": "3", "size": "21"},
{"_id": "08", "brand": "3", "size": "18"},
]
then I have the following options for a multiselect dropdown, the options are selected using the useState hook and stored as an array.
const dropdownData = [
{ label: '1', value: '1' },
{ label: '2', value: '2' },
{ label: '3', value: '3' },
]
So I need to filter the data array based on the options which have been selected and stored in the dropdown array
I have tried sorting the array with standard js array filtering but I cannot seem to get it to work with the multiselect using the useState hook and filtering as options are selected.