Closed bogdan2510 closed 9 months ago
check your lock file. Almost always, you'll have two versions (or the same version twice) of @tanstack/react-query
in there. also check node_modules if you have it there, twice. If you use pnpm, make sure you're on v8, because it had a resolution change regarding peer dependencies (see https://github.com/pnpm/pnpm/issues/5351)
with two versions of react-query, each one does createContext()
, so they have different contexts, which means the consumer can't see the context of the Provider. So even though you have a QueryClientProvider
, it will use a "different" react context than the consumer, so from the consumer side, there is no Provider.
I can't say more without seeing an actual reproduction for it. If my suggestion doesn't solve it, please feel free to re-open once you have a reproduction.
Hey. I don’t use trpc. I “solved” the problem by downgrading to version 5.0.0. :)
Mulțumesc , Bogdan Ioanas
From: Linus Nilsson Johnsen @.> Sent: Thursday, December 7, 2023 7:43:22 PM To: TanStack/query @.> Cc: Bogdan @.>; Mention @.> Subject: Re: [TanStack/query] No QueryClient set, use QueryClientProvider to set one (Issue #6432)
Hi @bogdan2510https://github.com/bogdan2510
I came across your issue since i am encountering a similar problem in my monorepo.
Given that this issue appears in production builds and considering your setup within a monorepo, I'm curious to know if you're using trpc or any other dependency that might indirectly utilize React Query in a different package inside your monorepo. This could potentially be a source of the problem, especially if there's some sort of conflict or misconfiguration between packages.
In my case, I'm also using a monorepo and wondering if there's a shared underlying cause. Have you explored this angle, or do you have any insights on whether such dependencies might affect the behavior of React Query in a production environment?
— Reply to this email directly, view it on GitHubhttps://github.com/TanStack/query/issues/6432#issuecomment-1845810614, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABGAEDGDWFBYF2AZCSJWBBTYIH53VAVCNFSM6AAAAAA7ZEX54KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBVHAYTANRRGQ. You are receiving this because you were mentioned.Message ID: @.***>
check your lock file. Almost always, you'll have two versions (or the same version twice) of
@tanstack/react-query
in there. also check node_modules if you have it there, twice. If you use pnpm, make sure you're on v8, because it had a resolution change regarding peer dependencies (see pnpm/pnpm#5351)with two versions of react-query, each one does
createContext()
, so they have different contexts, which means the consumer can't see the context of the Provider. So even though you have aQueryClientProvider
, it will use a "different" react context than the consumer, so from the consumer side, there is no Provider.I can't say more without seeing an actual reproduction for it. If my suggestion doesn't solve it, please feel free to re-open once you have a reproduction.
I was having the same issue @bogdan2510 had, npm i
resolved my package-lock.json file and the error has gone!
i'm in a monorepo setup using nx.dev. i use yarn. i don't have duplicates of "@tanstack/react-query" in lock file. Now i experience the problem even in version 5.0.0. :(. @4Furki4 @TkDodo
I am facing the same issue with @tanstack/react-query version 5.17.19
Are you using expo, nx.dev?
I'm facing this issue with Expo and Nx.dev
same here
i have the same problem :(
Did any of you guys managed to solve it?
I was having the same issue here with expo and turborepo.
I followed the guide in the expo docs for setting up the project for a monorepo that says to change my entry point in the package json for a index.js that they provide and an env for expo-router.
What was happening was that when I added the config they provide, the expo-router stopped working properly and the _layout was being ignored.
Because of that, the QueryProvider that was placed inside the root _layout wasn't being instantiated.
That was causing the issue.
What I did was just leave everything as it was before, with my package.json "main" pointed to the expo-router/entry:
"main": "expo-router/entry",
For what I can see everyone here that is having this issue is also using a monorepo. So probably y'all made that change in the package.json too. I believe that maybe this solution will also work for y'all.
@antonyleme I've seen your PR here https://github.com/expo/expo/pull/30536 but it's not working for me. My setup is a nx project with expo application.
"nx": "19.6.0",
"@nx/expo": "19.6.0",
"expo": "~51.0.28",
"expo-router": "~3.5.23",
"@tanstack/react-query": "^5.51.23",
"@tanstack/react-query-devtools": "^5.51.23",
Everything is up to date. I had the index.js
file importing the expo-router/enty
and ReactQuery wasn't being setup. Then I changed to main: "expo-router/entry" at package.json
and the problem still happening.
I'm unsure where the problem could be: react query, nx or expo-router.
The logs of the production apk:
Also, when doing console.log(queryClient)
it outputs {}
.
Dev apk DOES work pretty well.
Did you guys have any success? How can I debug this situation? I'm down to cooperate with testing @TkDodo .
Describe the bug
I have an expo app inside nx.dev monorepo. all is good on dev but when i do a production build i get "No QueryClient set, use QueryClientProvider to set one".
main entry point is this:
import { useLocalStorage } from '/hooks';
import React from 'react'; import { QueryClient } from '@tanstack/react-query'; import { PersistQueryClientProvider } from '@tanstack/react-query-persist-client'; import { createSyncStoragePersister } from '@tanstack/query-sync-storage-persister'; import * as Sentry from 'sentry-expo'; import Root from './Root';
Your minimal, reproducible example
This is only for productions builds
Steps to reproduce
This is happening only on production build. I don't have any ideea how to create a reproduction of this.
Expected behavior
To work
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
macOS
Tanstack Query adapter
react-query
TanStack Query version
5.7.2
TypeScript version
4.9.4
Additional context
Sentry is saying that error occoured in a custom hook that is inside the libs folder(im using nx monorepo.)
this is the hook:
and this in the apps folder(i only have a expo app)