From 650c69abcd293bc302da3c2bcdc9503f976ffe7d Mon Sep 17 00:00:00 2001 From: Wonsuk Choi Date: Mon, 26 Oct 2026 02:26:34 +0900 Subject: [PATCH] docs(framework): write snippet durations in 'count * unit * 1000' order (#12381) --- docs/framework/angular/guides/paginated-queries.md | 2 +- docs/framework/react/guides/important-defaults.md | 2 +- docs/framework/react/guides/migrating-to-v5.md | 2 +- docs/framework/react/guides/mutations.md | 2 +- docs/framework/react/guides/prefetching.md | 4 ++-- .../react/plugins/createAsyncStoragePersister.md | 2 +- docs/framework/react/plugins/createPersister.md | 8 ++++---- .../framework/react/plugins/createSyncStoragePersister.md | 2 +- docs/framework/react/plugins/persistQueryClient.md | 8 ++++---- docs/framework/solid/overview.md | 2 +- docs/framework/vue/guides/custom-client.md | 2 +- docs/framework/vue/guides/mutations.md | 2 +- docs/framework/vue/guides/prefetching.md | 2 +- docs/framework/vue/guides/ssr.md | 4 ++-- docs/framework/vue/plugins/createPersister.md | 8 ++++---- 15 files changed, 26 insertions(+), 26 deletions(-) diff --git a/docs/framework/angular/guides/paginated-queries.md b/docs/framework/angular/guides/paginated-queries.md index 1aa5ebdc7f..011db8a796 100644 --- a/docs/framework/angular/guides/paginated-queries.md +++ b/docs/framework/angular/guides/paginated-queries.md @@ -78,7 +78,7 @@ export class PaginationExampleComponent { queryKey: ['projects', this.page()], queryFn: () => lastValueFrom(fetchProjects(this.page())), placeholderData: keepPreviousData, - staleTime: 5000, + staleTime: 5 * 1000, })) constructor() { diff --git a/docs/framework/react/guides/important-defaults.md b/docs/framework/react/guides/important-defaults.md index 1458ff9791..68277f9c39 100644 --- a/docs/framework/react/guides/important-defaults.md +++ b/docs/framework/react/guides/important-defaults.md @@ -28,7 +28,7 @@ Out of the box, TanStack Query is configured with **aggressive but sane** defaul - Query results that have no more active instances of `useQuery`, `useInfiniteQuery` or query observers are labeled as "inactive" and remain in the cache in case they are used again at a later time. - By default, "inactive" queries are garbage collected after **5 minutes**. - > To change this, you can alter the default `gcTime` for queries to something other than `1000 * 60 * 5` milliseconds. + > To change this, you can alter the default `gcTime` for queries to something other than `5 * 60 * 1000` milliseconds. - Queries that fail are **silently retried 3 times, with exponential backoff delay** before capturing and displaying an error to the UI. diff --git a/docs/framework/react/guides/migrating-to-v5.md b/docs/framework/react/guides/migrating-to-v5.md index bc99edbb8d..e7da027e29 100644 --- a/docs/framework/react/guides/migrating-to-v5.md +++ b/docs/framework/react/guides/migrating-to-v5.md @@ -207,7 +207,7 @@ Almost everyone gets `cacheTime` wrong. It sounds like "the amount of time that `gc` is referring to "garbage collect" time. It's a bit more technical, but also a quite [well known abbreviation]() in computer science. ```tsx -const MINUTE = 1000 * 60; +const MINUTE = 60 * 1000; const queryClient = new QueryClient({ defaultOptions: { diff --git a/docs/framework/react/guides/mutations.md b/docs/framework/react/guides/mutations.md index 78d2df9f43..0defe155d0 100644 --- a/docs/framework/react/guides/mutations.md +++ b/docs/framework/react/guides/mutations.md @@ -359,7 +359,7 @@ const persister = createAsyncStoragePersister({ const queryClient = new QueryClient({ defaultOptions: { queries: { - gcTime: 1000 * 60 * 60 * 24, // 24 hours + gcTime: 24 * 60 * 60 * 1000, // 24 hours }, }, }) diff --git a/docs/framework/react/guides/prefetching.md b/docs/framework/react/guides/prefetching.md index 917f2d4409..e5afc00d3f 100644 --- a/docs/framework/react/guides/prefetching.md +++ b/docs/framework/react/guides/prefetching.md @@ -31,7 +31,7 @@ Prefetching a query uses the `query` method. This method by default will For prefetching you often want to modify these defaults: - Out of the box, `query` uses the default `staleTime` configured for the `queryClient` to determine whether existing data in the cache is fresh or needs to be fetched again -- You can also pass a specific `staleTime` like this: `query({ queryKey: ['todos'], queryFn: fn, staleTime: 5000 })` +- You can also pass a specific `staleTime` like this: `query({ queryKey: ['todos'], queryFn: fn, staleTime: 5 * 1000 })` - This `staleTime` is only used for that query fetch, you still need to set it for any `useQuery` call as well - If you want to always return data if it's available in the cache regardless of the default `staleTime`, you can pass `"static"` in for `staleTime`. - Tip: If you are prefetching on the server, set a default `staleTime` higher than `0` for that `queryClient` to avoid having to pass in a specific `staleTime` to each prefetch call @@ -98,7 +98,7 @@ function ShowDetailsButton() { queryFn: getDetailsData, // Prefetch only fires when data is older than the staleTime, // so in a case like this you definitely want to set one - staleTime: 60000, + staleTime: 60 * 1000, }).catch(noop) } diff --git a/docs/framework/react/plugins/createAsyncStoragePersister.md b/docs/framework/react/plugins/createAsyncStoragePersister.md index 346de5fb23..f290c111bf 100644 --- a/docs/framework/react/plugins/createAsyncStoragePersister.md +++ b/docs/framework/react/plugins/createAsyncStoragePersister.md @@ -46,7 +46,7 @@ import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persi const queryClient = new QueryClient({ defaultOptions: { queries: { - gcTime: 1000 * 60 * 60 * 24, // 24 hours + gcTime: 24 * 60 * 60 * 1000, // 24 hours }, }, }) diff --git a/docs/framework/react/plugins/createPersister.md b/docs/framework/react/plugins/createPersister.md index fef03ed36b..a9cf3479ea 100644 --- a/docs/framework/react/plugins/createPersister.md +++ b/docs/framework/react/plugins/createPersister.md @@ -52,13 +52,13 @@ import { experimental_createQueryPersister } from '@tanstack/query-persist-clien const persister = experimental_createQueryPersister({ storage: AsyncStorage, - maxAge: 1000 * 60 * 60 * 12, // 12 hours + maxAge: 12 * 60 * 60 * 1000, // 12 hours }) const queryClient = new QueryClient({ defaultOptions: { queries: { - gcTime: 1000 * 30, // 30 seconds + gcTime: 30 * 1000, // 30 seconds persister: persister.persisterFn, }, }, @@ -81,7 +81,7 @@ This utility might be used along `setQueryData` to persist optimistic update to ```tsx const persister = experimental_createQueryPersister({ storage: AsyncStorage, - maxAge: 1000 * 60 * 60 * 12, // 12 hours + maxAge: 12 * 60 * 60 * 1000, // 12 hours }) const queryClient = useQueryClient() @@ -210,7 +210,7 @@ The default options are: ```tsx { prefix = 'tanstack-query', - maxAge = 1000 * 60 * 60 * 24, + maxAge = 24 * 60 * 60 * 1000, serialize = JSON.stringify, deserialize = JSON.parse, refetchOnRestore = true, diff --git a/docs/framework/react/plugins/createSyncStoragePersister.md b/docs/framework/react/plugins/createSyncStoragePersister.md index 912b48f446..a6fea61463 100644 --- a/docs/framework/react/plugins/createSyncStoragePersister.md +++ b/docs/framework/react/plugins/createSyncStoragePersister.md @@ -47,7 +47,7 @@ import { createSyncStoragePersister } from '@tanstack/query-sync-storage-persist const queryClient = new QueryClient({ defaultOptions: { queries: { - gcTime: 1000 * 60 * 60 * 24, // 24 hours + gcTime: 24 * 60 * 60 * 1000, // 24 hours }, }, }) diff --git a/docs/framework/react/plugins/persistQueryClient.md b/docs/framework/react/plugins/persistQueryClient.md index 2597610f35..22991472e2 100644 --- a/docs/framework/react/plugins/persistQueryClient.md +++ b/docs/framework/react/plugins/persistQueryClient.md @@ -27,7 +27,7 @@ Due to a JavaScript limitation, the maximum allowed `gcTime` is about [24 days]( const queryClient = new QueryClient({ defaultOptions: { queries: { - gcTime: 1000 * 60 * 60 * 24, // 24 hours + gcTime: 24 * 60 * 60 * 1000, // 24 hours }, }, }) @@ -99,7 +99,7 @@ You can use this to restore the cache at moment(s) you choose. persistQueryClientRestore({ queryClient, persister, - maxAge = 1000 * 60 * 60 * 24, // 24 hours + maxAge = 24 * 60 * 60 * 1000, // 24 hours buster = '', hydrateOptions = undefined, }) @@ -118,7 +118,7 @@ This functionality is preserved from version 3.x. persistQueryClient({ queryClient, persister, - maxAge = 1000 * 60 * 60 * 24, // 24 hours + maxAge = 24 * 60 * 60 * 1000, // 24 hours buster = '', hydrateOptions = undefined, dehydrateOptions = undefined, @@ -189,7 +189,7 @@ import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persi const queryClient = new QueryClient({ defaultOptions: { queries: { - gcTime: 1000 * 60 * 60 * 24, // 24 hours + gcTime: 24 * 60 * 60 * 1000, // 24 hours }, }, }) diff --git a/docs/framework/solid/overview.md b/docs/framework/solid/overview.md index 6c57f35b40..69efa1e7c7 100644 --- a/docs/framework/solid/overview.md +++ b/docs/framework/solid/overview.md @@ -86,7 +86,7 @@ function App() { if (!result.ok) throw new Error('Failed to fetch data') return result.json() }, - staleTime: 1000 * 60 * 5, // 5 minutes + staleTime: 5 * 60 * 1000, // 5 minutes throwOnError: true, // Throw an error if the query fails })) diff --git a/docs/framework/vue/guides/custom-client.md b/docs/framework/vue/guides/custom-client.md index cadf592524..c7bbeee560 100644 --- a/docs/framework/vue/guides/custom-client.md +++ b/docs/framework/vue/guides/custom-client.md @@ -16,7 +16,7 @@ If You provide `QueryClientConfig`, `QueryClient` instance will be created inter ```tsx const vueQueryPluginOptions: VueQueryPluginOptions = { queryClientConfig: { - defaultOptions: { queries: { staleTime: 3600 } }, + defaultOptions: { queries: { staleTime: 60 * 60 * 1000 } }, }, } app.use(VueQueryPlugin, vueQueryPluginOptions) diff --git a/docs/framework/vue/guides/mutations.md b/docs/framework/vue/guides/mutations.md index df63dd07d1..674476159d 100644 --- a/docs/framework/vue/guides/mutations.md +++ b/docs/framework/vue/guides/mutations.md @@ -63,7 +63,7 @@ function addTodo() { const queryClient = new QueryClient({ defaultOptions: { queries: { - gcTime: 1000 * 60 * 60 * 24, // 24 hours + gcTime: 24 * 60 * 60 * 1000, // 24 hours }, }, }) diff --git a/docs/framework/vue/guides/prefetching.md b/docs/framework/vue/guides/prefetching.md index 12617657c3..7a945b2e17 100644 --- a/docs/framework/vue/guides/prefetching.md +++ b/docs/framework/vue/guides/prefetching.md @@ -24,7 +24,7 @@ const prefetchTodos = async () => { [//]: # 'ExamplePrefetching' - If **fresh** data for this query is already in the cache, the data will not be fetched -- If a `staleTime` is passed e.g. `queryClient.query({ queryKey: ['todos'], queryFn: fn, staleTime: 5000 })` and the data is older than the specified `staleTime`, the query will be fetched +- If a `staleTime` is passed e.g. `queryClient.query({ queryKey: ['todos'], queryFn: fn, staleTime: 5 * 1000 })` and the data is older than the specified `staleTime`, the query will be fetched - As `useQuery` will retry fetches and handle errors, you can use `void` to ignore the promise from `query` and `.catch(noop)` to ignore errors. - If you want to always return cached data when it exists, use `staleTime: 'static'` - If no instances of `useQuery` appear for a prefetched query, it will be deleted and garbage collected after the time specified in `gcTime`. diff --git a/docs/framework/vue/guides/ssr.md b/docs/framework/vue/guides/ssr.md index 60e4c680aa..716c2a6353 100644 --- a/docs/framework/vue/guides/ssr.md +++ b/docs/framework/vue/guides/ssr.md @@ -32,7 +32,7 @@ export default defineNuxtPlugin((nuxt) => { // Modify your Vue Query global settings here const queryClient = new QueryClient({ - defaultOptions: { queries: { staleTime: 5000 } }, + defaultOptions: { queries: { staleTime: 5 * 1000 } }, }) const options: VueQueryPluginOptions = { queryClient } @@ -82,7 +82,7 @@ import { VueQueryPlugin, QueryClient, hydrate } from '@tanstack/vue-query' export default (context) => { // Modify your Vue Query global settings here const queryClient = new QueryClient({ - defaultOptions: { queries: { staleTime: 5000 } }, + defaultOptions: { queries: { staleTime: 5 * 1000 } }, }) if (process.server) { diff --git a/docs/framework/vue/plugins/createPersister.md b/docs/framework/vue/plugins/createPersister.md index fd3eec58d9..79eaed8643 100644 --- a/docs/framework/vue/plugins/createPersister.md +++ b/docs/framework/vue/plugins/createPersister.md @@ -49,13 +49,13 @@ import { experimental_createQueryPersister } from '@tanstack/query-persist-clien const persister = experimental_createQueryPersister({ storage: localStorage, - maxAge: 1000 * 60 * 60 * 12, // 12 hours + maxAge: 12 * 60 * 60 * 1000, // 12 hours }) const queryClient = new QueryClient({ defaultOptions: { queries: { - gcTime: 1000 * 30, // 30 seconds + gcTime: 30 * 1000, // 30 seconds persister: persister.persisterFn, }, }, @@ -78,7 +78,7 @@ This utility might be used along `setQueryData` to persist optimistic update to ```tsx const persister = experimental_createQueryPersister({ storage: localStorage, - maxAge: 1000 * 60 * 60 * 12, // 12 hours + maxAge: 12 * 60 * 60 * 1000, // 12 hours }) const queryClient = useQueryClient() @@ -207,7 +207,7 @@ The default options are: ```tsx { prefix = 'tanstack-query', - maxAge = 1000 * 60 * 60 * 24, + maxAge = 24 * 60 * 60 * 1000, serialize = JSON.stringify, deserialize = JSON.parse, refetchOnRestore = true,