What I am currently trying to do is to filter an existing list of items by the select ones in a select dropdown. Meaning that, whenever I click on a item, I want to remove it from the available options (so I can't add it twice to the list).
The problem that I'm having is that whenever I filter this item out, I don't display it on the screen (cause I've removed it from the list). How can I remove an item from the list of available options but still display it on the screen? Also if I decide to change the item again, will the previous one show in the list again?
I suspect the issue might be in my filtering function:
const filterElements = (selectedPerson) => {
let filteredList = people.filter((person) => {
return selectedPerson.id !== person.id;
});
setPeople(filteredList);
};