const filteredata= basketdata.filter(obj => {
return obj.id !== item.id;
});
setBasket([...filteredata]);
console.log('basketdata',basketdata);
I am removing items from my array when same items available. After removing item trying to print the array in console but it doesn't printing the actual value. Also I know that setState()
will not update immediately.
How can I solve this issue?