TypeError: _reactQuery.QueryClient is not a constructor
See original GitHub issueQueryClient is not a constructor when write a unit test with jest
import { QueryClient, QueryClientProvider } from "react-query";
const queryClient = new QueryClient({
defaultOptions: {
queries: {
retry: 2,
},
},
});
export function App() {
return (
<QueryClientProvider client={queryClient}>
<Dashboard />
</QueryClientProvider>
);
}
export default App;
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
react-query useQueryClient is not a function in Jest or ...
Second situation: Type error react_query_1.QueryClient is not a constructor. The scenario is: I have react-query configured in a next-js project ...
Read more >QueryClient in react-query is not a constructor when ... - GitHub
bug report I built this code without --no-scope-hoist $ parcel build public/index.html import { QueryClient } from "react-query"; export const queryClient ...
Read more >Migrating to React Query 3 - TanStack
It returns the provided queryClient for its component tree and shouldn't need much tweaking beyond a rename. Query key parts/pieces are no longer...
Read more >What I learned from React-Query, and why I won't use it again
We think that such a process should not be managed within the component. It affects the entire app, even beyond (the Iframe), and...
Read more >Testing React Query | TkDodo's blog
Let's take a look at how to efficiently test custom useQuery hooks and components using them.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You asked the same on stackoverflow: https://stackoverflow.com/questions/67354617/typeerror-reactquery-default-is-not-a-constructor
In my case, this error message was related to an improper
jest.mockthat I had added earlier.The fix was to change this:
to the following:
My initial block of code overrides the entire module, when my intent was just to override the
useQueryfunction and retain the rest. Hope this helps someone else who might be stuck on this!