Premise: i got this error only on production (next.js) and not always, just sometimes.
I use the package @tanstack/react-query in my next.js project. Sometimes in production, out of nowhere, i got the issue
No QueryClient set, use QueryClientProvider to set one
and the app breaks. This is my implementation
export default function App({ Component, pageProps }: AppProps) {
const [queryClient] = useState(() => new QueryClient(options));
return (
<QueryClientProvider client={queryClient}>
<ErrorBoundary>
<HydrationBoundary state={pageProps.dehydratedState}>
<Providers pageProps={pageProps}>
<Component {...pageProps} />
</Providers>
</HydrationBoundary>
</ErrorBoundary>
</QueryClientProvider>
);
}
Note that in the same project i use another package, wagmi, which uses @tanstack/react-query too but of a different version (i use 5.0.0, they use 4.3.2).
I appreciate any tips on how to solve this.