query icon indicating copy to clipboard operation
query copied to clipboard

remove contextSharing

Open TkDodo opened this issue 3 years ago • 0 comments

context

The QueryClientProvider has a prop contextSharing: boolean. The docs say:

Set this to true to 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 contextSharing in v4
  • Remove contextSharing from QueryClientProvider in v5

TkDodo avatar Dec 23 '22 07:12 TkDodo