Replies: 2 comments 6 replies
-
as you said, this problem is taken care of in v5:
it doesn't matter where you get the client from - can be passed as a prop or can be read from window. I'm just wondering: How is adding a another value to every useQuery call better than wrapping all entrypoints in a Provider?
|
Beta Was this translation helpful? Give feedback.
-
Hey, thanks for the reply! v5 does indeed solve our issue, but we're in a bit of a bind in a few ways. We have a lot of tech debt which is preventing us from upgrading to React 18 (we're actively working on it!) and we're unsure of how long v5 will be in alpha/beta. Although we will have plenty of time to wait for v5's release while we upgrade to React 18, we're also needing a solution for shared queries fairly soon. We've only used it in a few of our services so far but we're wanting to start a full adoption for the rest of our team. As for passing queryClient to each query call vs using a provider, we not only have 30 services but some of them also export components that can be used by other services. e.g. Our files service exports a file browser that other services can use. In this case if one service is not wrapped in a provider and uses this exported component we'll get a query client not found error. So we also have to wrap all of these shareable components in their own provider until we can ensure that every service is wrapped. So to allow our team to start gradually introducing react-query it seemed like just passing in the query client explicitly is the safest method for us. We were also thinking of building some global wrappers that will pass in our global client automatically. We're still discussing our options but this is where we're at right now. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
for our microfrontend, we have over 30 react apps, and each app can mount simultaneously without a common react root (using single spa).
to use react query, we would need every single react app to be wrapped in a
QueryClientProvider
, since we don't have a common root.My proposal is to allow for a
queryClient
that can be assigned to the window, and read inuseQueryClient
as a fallback for context.with this small change, we can avoid wrapping every single react app...
another option is to follow the new v5 API and allow
queryClient
as an option:thoughts?
Beta Was this translation helpful? Give feedback.
All reactions