-
Context: Using Next.js version 14.2.1 along with Problem: When a user opens the modal window and performs an update, the category ID in the URL changes dynamically. After sending data to the server, two queries are invalidated through Reproducing the Problem:
LINK: sanbox |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
not exactly sure what happens here, but if you keep the mutation pending while the invalidations happen, you don't run into this:
|
Beta Was this translation helpful? Give feedback.
I found the problem, and on one hand, I'm glad, but on the other, I'm disappointed that I now need to rewrite 20 requests. :) The issue lies with
Next.js
, specifically in their new approach where you can use requests on the server side in a regular file using'use server'
—I forgot what this approach is called. The problem is that it breaks any requests if they happen simultaneously and there is a change in the address bar. I tried writing my function throughfetch
to the data retrieval function where'use server'
is used and got the same behavior as withtanstack-query
. The solution is very simple: useAPI routes
for data retrieval. In this case, both tanstack-query and fetch, and everyth…