TanStackT
TanStack8mo ago
23 replies
dead-brown

tanstack query as a cache

Hi, I am using tanstack query instead of default router cache. Example from docs is using:
    // Since we're using React Query, we don't want loader calls to ever be stale
    // This will ensure that the loader is always called when the route is preloaded or visited
    defaultPreloadStaleTime: 0,


What is the difference between defaultStaleTime vs defaultPreloadStaleTime?


That's my loader: which option is responsible for making it run only once -> The one in the querOptions or any of those 2 above?
    return queryClient.ensureQueryData({
        queryKey: ["lobby"],
        queryFn: getLobby,
        staleTime: Number.POSITIVE_INFINITY,
    });
Was this page helpful?