I have a dropdown which controls state: [selected, setSelected]. This state is created into a flat array and then mapped into icons.
When the icon is selected I would like it to then remove that target specifically from the array. I assume this is just a simple (e) => onClick but am unsure how to write it.
Please see how my state is created:
const onPerksClick = (val) => {
console.log({ val });
if (!selected.includes(val)) {
setSelected((prev) => [...prev, val]);
}
};
i then map this into icons and different things. I would like to include this so when it's clicked it will remove it from the array.
<BenefitsContainer>
{selected.map((perkTitle) => (
<SelectionBoxesChoiceOption >
{perkTitle=="Equity" &&
<BalanceIcon style={{ color: "white"}}/>
}
</SelectionBoxesChoiceOption>
))}
</BenefitsContainer>