Item is showing back in the UI after deletion #5625
Replies: 3 comments 10 replies
-
In case you are using v4 of tanstack query, you might be calling |
Beta Was this translation helpful? Give feedback.
-
start by double checking the network request (browser devtools, network tab) that is fired by the invalidation. I guess this request returns the whole list, so if your item is in that list it's a backend issue. |
Beta Was this translation helpful? Give feedback.
-
Hi, thank you for your answer. Anything that I might missing? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am new to React Query and I am trying to delete an item and immediatly update the UI.
This is my custom hook for deletion:
This is the logic of the backend:
When queryClient.invalidateQueries(['board', context!.id]) is reached on onSuccess, the item is shown back / reappears on the UI, even though it is successfully deleted from the db.
on onMutate it is successfully undisplaying the deleted item only when reaching onSuccess it is reappearing.
*I am sure that the item is deleted from the database.
*the context is current and shown without the deleted item.
The thing is, I'm not sure how to even start debugging this case. I have a few more custom hooks that do the same exact logic, for example "useAddItem", and I don't have issues with the other ones.
Any help or guide will be appreciated. Thanks
Beta Was this translation helpful? Give feedback.
All reactions