Error: No QueryClient set, use QueryClientProvider to set one
The error is coming from this snippet
Where I try to fetch products by page.
the products routers look as follows:
And Inside of my
_app.tsx
component I am returning this:
So I have indeed set QueryClientProvider and passed the QueryClient
through.7 Replies
these are the contents of my
utils/api.ts
also, this application is part of a monorepo.
which I have recently migrated to pnpm from npm.
I wasn't getting this error when I was using npm.This is the full error if it helps:
This error is happening while generating the page
Remove the query client you manually added
Should fix the issue
Probbaly
I'm on mobile so can't see the error
And if it does you know what to Google to achieve what your Trying to achive
you mean the
queryClientRef.current
?The component yes
I've checked almost 10 Stackoverflow question abt this xD
and other sources
I've tried removing
QueryClientProvider
I saw that I only get the error on /products
and /
page
cuz...
those pages use useInfiniteQuery
all pages that fetch data using useInfiniteQuery
give me this error.
for example I don't get the error from /products/[slug]
which used useQuery
to get one product.
This theory is busted
now it's, when I navigate inside of the url instead of clicking on links that I get this error
for example, I click on the link that gets me to /
, I do not get the error.
for me to be able to see the navbar tho, I have to navigate from the url to localhost:3000/about
cuz no queries are being made in the about page
pnpm i @tanstack/react-query
That was the fix