Solution found!
https://github.com/TanStack/query/issues/3595
Hello! Need some help debugging an error that appears to be originating from react-query.
Error:
TypeError: React.createContext is not a function
at file:///home/node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js:5:32
at ModuleJob.run
at async Promise.all (index 0)
at async importModuleDynamicallyWrapper
Context:
Tried and experience this issue with nextjs 12.3.4 and 13.5.6 (Not using experimental server components)
Nodejs: 18.18.1
@tanstack/react-query: 5.0.0
@tanstack/react-query-devtools: 5.0.1
React and React DOM: 18.2.0
I experience no issues in local dev mode, everything works flawlessly.
After deployment I see the above error.
_app.tsx
import { QueryClientProvider } from '@/providers'
function App() {
return (
<QueryClientProvider>
<OurApp />
</QueryClientProvider>
)
}
QueryClientProvider.tsx
import { QueryClientProvider as Provider, QueryClient } from '@tanstack/react-query'
import { ReactQueryDevTools } from '@tanstack/react-query-devtools'
export function QueryClientProvider({ children }: { children: React.ReactNode }) {
const [queryClient] = useState(() => new QueryClient())
return (
<Provider client={queryClient}>
{children}
<ReactQueryDevtools initialIsOpen={false} />
</Provider>
)
}