I want to ask you is that immuteable or not ?
// Select all product options that you selected for each product we store it in an array
const [selectedProductOptions, setSelectedProductOptions] = useState<ISizeAndColors[] | []>([]);
findObj && setSelectedProductOptions(prev => {
return prev.map((el => {
if(el.product_id === currentProductID) {
return {
...el,
color,
size,
amount
}
} else {
return {
...el
}
}
}))
If not what I am doing then wrong ?