TanStackT
TanStack3y ago
2 replies
sad-indigo

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
    },
  },
}); 
`

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">'


What am I doing wrong?
Was this page helpful?