T
TanStack4y ago
harsh-harlequin

Should you avoid nesting QueryClient?

We have a large enterprise app with multiple teams working on features that use RQ. We're in the process of introducing a QueryClientProvider at the app's root level which would create nested clients. Is this something to avoid? I assume calls like queryClient.invalidateQueries will be limited to their closest provider, but I could see this being confusing in a large codebase.
2 Replies
variable-lime
variable-lime4y ago
Yes, calls into useQueryClient would take the nearest provider, though, you can pass a context info to useQueryClient to grab the right one, and thus create your own hooks like useSpecificQueryClient that wrap that behavior
harsh-harlequin
harsh-harlequinOP4y ago
Oh that's great to know, thanks @Tanner Linsley 👍

Did you find this page helpful?