Hello everyone i am developing an app that list products and add this items to basket. Its seems like e-comerce but a little bit different. This items has more details inside product because of this backend sends only a little bit information about product (id, title, desc). I want to take all data when product added to basket. It is working like expected but have one bug. If user add more item to basket at same time its lost data or duplicate data. I want to queue this process for secure data.
I just insert a queue state betweeen add button and add request, its like :
useEffect(() => {
if (queue.length > 0) {
setItemProps(queue[0]).then((response) => {
dispatch(addItem(response));
setQueue(queue.slice(1));
toast.success('Item added to basket');
})
}
}, [queue]);
I have problem like this
if adding product 1 2 3
state works like
1 2 3 1 2 1
state check itself last status. How to check state current value when changing state