-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: No QueryClient set, use QueryClientProvider to set one #7965
Comments
This issue has been filed many times. I know it seems that way, but it's not a react-query bug/issue. The most likely scenario is multiple versions of react-query or react in your codebase. I checked the lockfile, it doesn't seem that way, but Further, pnpm scopes the versions along with peerDependencies, so the actual version you're using is This problem is the same for all libraries that use react context to share some static instance (in our case, the QueryClient). If I'm correct, just not using next but e.g. a simple vite app for the reproduction where no magic with react versions is going on should make it work. I'm personally using an nx monorepo + vite with consumers/producers in different packages in the same app and it works just fine. For your specific situation, I would recommend to have the shared lib not only expose the custom hooks, but also the In the isolated, shared package, you can also pass the |
This is a bit strange, the previous versions (currently based on While sample is quite simple, with more complex library structures, it's hard for me to imagine pushing the By the way, it would be good if some example appeared in the documentation, with examples of use in monorepo or shared libraries, because unfortunately there are none, which is probably why this thread comes back like a boomerang. |
I have the same issue with Tanstack Router, after I updated to the latest version Edit: It's correct what @TkDodo, if you have multiple different version of react query it will broke. step to fix:
|
Describe the bug
When using the @tanstack/react-query v5 library within a Turborepo monorepo structure, specifically inside a shared library, the following error is thrown:
Your minimal, reproducible example
https://github.com/msobiecki/react-query-repro
Steps to reproduce
Reproduction Steps:
Demo:
Expected behavior
The @tanstack/react-query library should function as expected within the shared library.
How often does this bug happen?
Every time
Screenshots or Videos
Platform
Tanstack Query adapter
react-query
TanStack Query version
5.52.2
TypeScript version
5.3.3
Additional context
No response
The text was updated successfully, but these errors were encountered: