-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
Describe the bug
Note: I read this issue #3595 which is about using the useQuery hook from the third party lib.
In that issue @TkDodo mentioned that if the react and react-query version are same , It will work, when I try that it is not working.
Demo
I created one simple demo stackblitz (https://stackblitz.com/~/github.com/shmdhussain/react-query-third-party-lib) using monorepo.
use npm run start
to see the demo works,
Reproduce steps:
just click to comp1 (it works correctly) but when you click comp2 it wont work because of the error No QueryClient set, use QueryClientProvider to set one
explanation of my issue
In the demo, I placed my app @mymonorepo/my-app
which consumes two libs (@mymonorepo/my-lib-1
) and (@mymonorepo/my-lib-2
) (consider those two as 3rd party libs giving us custom hooks (useFetchIds' which internally uses the
useQuery`).
In @mymonorepo/my-lib-1
I just exported hook only and made the react query as external peer deps to be provided by consuming lib which is @mymonorepo/my-app
In @mymonorepo/my-lib-2
I exported/bundled hook along with the react query, in that case when consuming from my app is not working , when I debugged the bundled code of 3rd part lib found that useQuery from the 3rd party lib uses the context from the 3rd party lib rather than from the consuming app, which causes this issue.
By @TkDodo comment in the issue, If i use same version of react and react-query it should work, but not working. Am I missing anything here or any work around to make it work?
Thanks in advance for any help
Expected behavior
It should work from third party hooks.
How often does this bug happen?
None
Screenshots or Videos

Platform
- All
Tanstack Query adapter
None
TanStack Query version
5.75.5
TypeScript version
No response
Additional context
No response