-
-
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
Issues when separating queries into a nx monorepo library #7927
Comments
Hi, same problem here. Gonna check if it works upgrading the dependency on both sides |
I've just tried using version 5.51.1 without success. |
The thing is - we don't do anything special here. We create a react context, and expose the Provider as If reading from that context yields Now if you have two versions of react, or two versions of react-query (e.g. pnpm v7 used to duplicate your peerDependencies to give you two versions), the provider created from one version cannot be "seen" by the consumer with a different version, thus it thinks it cannot exist. In the minified js, you can often see this because functions are called You would likely have the exact same problem with any other library that exposes a react context and has a peerDependency on react itself. So the problem must be somewhere in your specific bundling setup, which honestly I'm not willing to look into. |
@TkDodo I though exactly about that |
@TkDodo thanks for the response! My setup is nothing but the default So, the problem would be in Do you have some tip or advice for me to keep debugging it? I'm willing to look into it deeply, but I'm out of ideas. |
Fixed the problem by isolating react-query into How it was How it is Now, only Apparently it's something related to nx bundling... I don't know 🤷 . |
Tanks @vendramini it's work for me |
Describe the bug
I do have a nx monorepo project. During development everything has been working out. When I try to compile a final apk to share it, I've got into this error:
ReactNativeJS Error: No QueryClient set, use QueryClientProvider to set one
.We do have some issues related: #5445 and #3595.
It turns out that nothing has really worked out to me. I still can't open the compiled apk.
So I tried to isolate the problem within a minimum nx monorepo:
Check out that it does work on development:
nx run-android myapp
. When I compile the final apk:nx build myapp --local --platform=android
it compiles, but when opening the appReact Query
complains aboutQueryClient
.Query Client is being defined only in one place. There's no duplicated versions of react-query neither react.
Thoughts?
Your minimal, reproducible example
https://github.com/vendramini/nx-rq-test
Steps to reproduce
nx run-android myapp
: it works, you will see both fetches on the screen (local one and another one from lib).nx build myapp --local --platform=android
: compile successfully, but crashes when opening it.Expected behavior
Don't crash and honor the single queryclient instance.
How often does this bug happen?
Every time
Screenshots or Videos
As you can see, we do have 2 lines of json response from api (this is development mode).
Crashes on final apk.
Platform
macOS, Android Tablet Emulator 7_WSVGA_API_34
Tanstack Query adapter
react-query
TanStack Query version
"@tanstack/react-query": "^5.51.24",
TypeScript version
"typescript": "~5.3.3"
Additional context
No response
The text was updated successfully, but these errors were encountered: