Skip to content
Discussion options

You must be logged in to vote

Hey @dil-atelegdi !

For me, your current approach (isolating the lib's QueryClient) is the right call.

But the issue with that is that TanStack Query uses React Context under the hood to distribute the QueryClient. So if your library and the host app ship different copies of @tanstack/react-query (even the same version, but duplicated in node_modules), they'll each create their own React context. That means that your library's useQuery calls won't find the host app's QueryClientProvider, and vice-versa.

So if you can't control version alignment (which seems realistic to me for a shared UI library), creating your own QueryClient inside the library and wrapping your components with your own…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by dil-atelegdi
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants