onSettled throws annot update a component (`HotReload`) while rendering a different component
Stack:
"next": "14.0.4"
"@tanstack/react-query": "^5.17.12"
I have server component that is prefetching data and storing in cache. Then i have mutation that is updating the state which is OK until i add this line of code:
also tried like this:
full mutation looks like this:
Issue that i'm facing is:
Not sure why is happening, tried to do optimistic update and filter variables from products
and status pending
and indeed i can see the variable coming from
But then error occurs and and app is crashing, if this line is commented IN:
onSettled: async () => await queryClient.invalidateQueries({ queryKey: ['products'] })
everything works no problems, any ideas?4 Replies
passive-yellow•2y ago
Show your QueryClientProvider
sunny-greenOP•2y ago
here is it:
hey @TkDodo 🔮 , do you have any thoughts on this 🙏 i really love the way optimistic updates are done and now even like it more when i can subscribe to mutation state but this
onSettled
phase is not letting me :X 😄
pretty pretty please 😊passive-yellow•2y ago
Show a reproduction in a code sandbox
sunny-greenOP•2y ago
somehow i make it work but now sure how :X 😄