Skip to content
Discussion options

You must be logged in to vote

You should probably snapshot your old value in onMutate and return it. See the docs.
Doing that would make your code a lot easier - rather than having to filter in onError - you would just do something like queryClient.setQueryData(previousValue).

As to why it doesn't work, I think it's because currently you're mutating the page in your map. You're only doing a shallow copy of the "cache", and when you're mapping you're not returning a new object of the page.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@Birkbjo
Comment options

Answer selected by zorro1rr
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants