You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The 'QueryClient' type does not have queryCache, mutationCache, defaultOptions, queryDefaults and four other properties of the 'QueryClient' type.
#9684
Closed
stoicjone opened this issue
Feb 26, 2024
· 3 comments
To set React Query's staleTime, I created a QueryClient instance, set defaultOptions.queries.staleTime, and passed it to the queryClient props in the Admin component as described in the official documentation.
I expected it to work the same as passing it to QueryClientProvider, but I get an error message saying a required property is missing.
What happened instead:
I get the following error message: The 'QueryClient' type does not have queryCache, mutationCache, defaultOptions, queryDefaults and four other properties of the 'QueryClient' type.
I ran this code locally and I'm not getting any errors. My Chrome version is different from yours but I'm not getting this error in Firefox either. Do you still get queryClient error if you run this code in a new React project?
@Nela62 If you look at the 'Environment' part of the issue I published, you can see that I am using the latest version, @tanstack/react-query v5. You are importing QueryClient from react-query, but I am importing it from @tanstack/react-query. As far as I know, react-query is version 3, and @tanstack/react-query is currently version 5. I understand that React-admin recently migrated react-query to v5. Is this correct? #9462
After creating a new project, I installed React-query(older version) and passed queryClient, but no error occurred. However, if I pass queryClient from @tanstack/react-query, I still get an error. Since it has been migrated to v5, I think it is right to import QueryClient from the latest version. Do I need to set all properties one by one? No related documentation found.
What you were expecting:
To set React Query's
staleTime
, I created aQueryClient
instance, setdefaultOptions.queries.staleTime
, and passed it to thequeryClient
props in theAdmin
component as described in the official documentation.I expected it to work the same as passing it to
QueryClientProvider
, but I get an error message saying a required property is missing.What happened instead:
I get the following error message: The 'QueryClient' type does not have queryCache, mutationCache, defaultOptions, queryDefaults and four other properties of the 'QueryClient' type.
Related code:
Environment
I don't know if this is basic behavior or if I'm missing something. I couldn't find any related documents or content either.
The text was updated successfully, but these errors were encountered: