remove contextSharing
context
The QueryClientProvider has a prop contextSharing: boolean. The docs say:
Set this to
trueto enable context sharing, which will share the first and at least one instance of the context across the window to ensure that if React Query is used across different bundles or microfrontends they will all use the same instance of context, regardless of module scoping.
To be honest - I don't really know how this property is working. There were some discussion on this issue that suggest that it is not really useful.
For microfrontends, isolation is often preferred. With v4, we introduced the option to pass a custom context, which allows for exactly that.
If you want your app to use the same client when it's composed of multiple packages, all you'd need to do is create one QueryClient in your app and let the different bundles pick those up. As long as they all use the same version of TanStack Query, this should work fine.
proposal
- ✅ Deprecate
contextSharingin v4 - Remove
contextSharingfromQueryClientProviderin v5