T
TanStack3y ago
harsh-harlequin

I cannot set a default cacheTime

Hello, I'm trying to set a default cache and staleTime when creating my queryClient
const queryClient = new QueryClient({
defaultOptions: {
queries: {
cacheTime: 15 * (60 * 1000), // 15 mins
staleTime: 10 * (60 * 1000), // 10 mins
},
},
});
const queryClient = new QueryClient({
defaultOptions: {
queries: {
cacheTime: 15 * (60 * 1000), // 15 mins
staleTime: 10 * (60 * 1000), // 10 mins
},
},
});
` But it complains on cacheTime with the message
Type '{ cacheTime: number; staleTime: number; }' is not assignable to type 'Omit<QueryObserverOptions<unknown, Error, unknown, unknown, QueryKey, never>, "suspense">'.
Object literal may only specify known properties, and 'cacheTime' does not exist in type 'Omit<QueryObserverOptions<unknown, Error, unknown, unknown, QueryKey, never>, "suspense">'
Type '{ cacheTime: number; staleTime: number; }' is not assignable to type 'Omit<QueryObserverOptions<unknown, Error, unknown, unknown, QueryKey, never>, "suspense">'.
Object literal may only specify known properties, and 'cacheTime' does not exist in type 'Omit<QueryObserverOptions<unknown, Error, unknown, unknown, QueryKey, never>, "suspense">'
What am I doing wrong?
2 Replies
ambitious-aqua
ambitious-aqua3y ago
Migrating to TanStack Query v5 | TanStack Query Docs
Breaking Changes v5 is a major version, so there are some breaking changes to be aware of:
harsh-harlequin
harsh-harlequinOP3y ago
Yes, that is it! Thanks

Did you find this page helpful?