Replies: 1 comment 1 reply
-
what does getData return? probably needs a complete example repo for analysis |
Beta Was this translation helpful? Give feedback.
1 reply
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
-
I'm trying to get my head around when using the Router in combination with TanStack Query.
So far, I'm very happy with it, there are just a few things I don't understand.
I have this Route component:
If I use it like that, I get one network request and everything is fine, but there is no suspension.
If I
return
the data from the loader function, I get the component to suspend but I get an extra network request fired.If I use
useSuspenseQuery
I get what I want (only one request) but with a subtle difference:return
, it immediately suspends, fires the request and when it data is ready it renders the componentreturn
, it starts the request first, then suspends and when data is ready the component rendersIn both cases there are only one request.
My question is why are there two request when I return from the loader with
useQuery
? I loggedconst result = Route.useLoaderData();
at the top and the data is there when the component first rendered, how comeuseQuery
is not aware of it?Shouldn't the query already be in the cache?
Beta Was this translation helpful? Give feedback.
All reactions