Next.js Discord

Discord Forum

Optimistic updates strange behaviour

Unanswered
Siamese Crocodile posted this in #help-forum
Open in Discord
Original message was deleted.

4 Replies

Siamese Crocodile
Hi, I've a strange problem with optimistic updates, I am using next 14.0.3

Above code sometimes works as expected but sometimes after clicking delete button optimistic state changes correctly and after a second or so the item returns back to the optimisticCart
Mutation is successful so when I refresh the page the item isn't there
Argentine hake
Maybe you need to deconstruct state.products the same way you’re deconstructing state?
Siamese Crocodile
I dont think I get it @Argentine hake Could you elaborate?
Argentine hake
Looking at it again, I think I was on the wrong track. Sorry.