Double query call using "use"
Hi, this is my first interaction in this server.
I am using the experimental_prefetchInRender feature, and i experimenting double query calls when change the queryKey data using startTransition.
Is this normal?
I have a demo (check console.logs) https://stackblitz.com/edit/vitejs-vite-o3xw8dhk?file=src%2FApp.jsx
Thanks!
maguirreoptime
StackBlitz
Revisando use y React - Query - StackBlitz
Next generation frontend tooling. It's fast!
3 Replies
stormy-goldOP•2mo ago
I think that for now the experimental_prefetchInRender must be commented on the project that I working, thanks
like-gold•2mo ago
you don't have a
staleTime set so what happens is that prefetch in render during the transition triggers the fetch before the oberver is mounted, then, when it's finished, react mounts the component and that triggers a refetchOnMount.
for useSuspenseQuery, we force a minimal staleTime of 1s because it has the same problem but since we don't know how you use use (hah) or if you use transitions, we don't know that so you need to do that yourselfstormy-goldOP•2mo ago
ok, thanks for the response.
So, the use of a staleTime in this case is a valid solution to prevent the double query call.