TanStackT
TanStack4y ago
8 replies
full-green

Prevent nested requests using setQueryData

Hello.
I've logged in user in the top of app and manually set user data to user's query cache with queryClient.setQueryData(userKey, user)
And I don't expect additional requests in nested components which included useUserQuery with same key. But nested components send another request.
Hot to prevent it? Do I do something wrong?
I would like to combine two custom hook with query (login and fetching user) but I don't know how. That's why I put cache manually.
Was this page helpful?