TanStackT
TanStack2y ago
3 replies
sacred-rose

QueryClientProvider v5 context

Hey I'm reading the migrating to v5 docs: https://tanstack.com/query/latest/docs/framework/react/guides/migrating-to-v5


Under the header "The contextSharing prop has been removed from QueryClientProvider"
https://tanstack.com/query/latest/docs/framework/react/guides/migrating-to-v5#the-contextsharing-prop-has-been-removed-from-queryclientprovider

It recommends using the context property for sharing the query client across packages/apps:

If you wish to use the same query client across multiple packages of an application, you can create a QueryClient in your application and then let the bundles share this through the context property of the QueryClientProvider.

context was removed from the QueryClientProvider in v5 as well though?
No context on latest v5+:
https://tanstack.com/query/latest/docs/framework/react/reference/QueryClientProvider#queryclientprovider
context on v4:
https://tanstack.com/query/v4/docs/framework/react/reference/QueryClientProvider
Breaking Changes

v5 is a major version, so there are some breaking changes to be aware of:
Migrating to TanStack Query v5 | TanStack Query React Docs
Use the QueryClientProvider component to connect and provide a QueryClient to your application:

`tsx
QueryClientProvider | TanStack Query React Docs
Use the QueryClientProvider component to connect and provide a QueryClient to your application:

`tsx
QueryClientProvider | TanStack Query React Docs
Was this page helpful?