From e6503b099088c5d8ee3987533c8a67424ca67ec9 Mon Sep 17 00:00:00 2001 From: Wonsuk Choi Date: Tue, 25 Aug 2026 23:28:25 +0900 Subject: [PATCH] docs(preact-query): cross-link hooks with their options factories via '@see' and move the infinite-query caveat to '@remarks' (#11289) --- .../functions/infiniteQueryOptions.md | 18 +++++++-- .../reference/functions/mutationOptions.md | 12 +++++- .../reference/functions/queryOptions.md | 18 +++++++-- .../reference/functions/useInfiniteQuery.md | 40 +++++++++++++++---- .../preact/reference/functions/useMutation.md | 6 ++- .../preact/reference/functions/useQuery.md | 18 +++++++-- .../preact-query/src/infiniteQueryOptions.ts | 3 ++ packages/preact-query/src/mutationOptions.ts | 2 + packages/preact-query/src/queryOptions.ts | 3 ++ packages/preact-query/src/useInfiniteQuery.ts | 16 ++++++-- packages/preact-query/src/useMutation.ts | 1 + packages/preact-query/src/useQuery.ts | 3 ++ 12 files changed, 117 insertions(+), 23 deletions(-) diff --git a/docs/framework/preact/reference/functions/infiniteQueryOptions.md b/docs/framework/preact/reference/functions/infiniteQueryOptions.md index fc12a66b2f..d28fe91935 100644 --- a/docs/framework/preact/reference/functions/infiniteQueryOptions.md +++ b/docs/framework/preact/reference/functions/infiniteQueryOptions.md @@ -9,7 +9,7 @@ title: infiniteQueryOptions function infiniteQueryOptions(options): UseInfiniteQueryOptions & object & QueryKeyWithDataTag, TError>; ``` -Defined in: [preact-query/src/infiniteQueryOptions.ts:156](https://github.com/TanStack/query/blob/main/packages/preact-query/src/infiniteQueryOptions.ts#L156) +Defined in: [preact-query/src/infiniteQueryOptions.ts:157](https://github.com/TanStack/query/blob/main/packages/preact-query/src/infiniteQueryOptions.ts#L157) You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`. @@ -51,6 +51,10 @@ The [DefinedInitialDataInfiniteOptions](../type-aliases/DefinedInitialDataInfini The same options object, typed so that `queryKey` carries the inferred data type. +### See + +[useInfiniteQuery](useInfiniteQuery.md) to run an infinite query with these options. + ### Example ```tsx @@ -76,7 +80,7 @@ function Projects() { function infiniteQueryOptions(options): OmitKeyof, "queryFn"> & object & QueryKeyWithDataTag, TError>; ``` -Defined in: [preact-query/src/infiniteQueryOptions.ts:231](https://github.com/TanStack/query/blob/main/packages/preact-query/src/infiniteQueryOptions.ts#L231) +Defined in: [preact-query/src/infiniteQueryOptions.ts:233](https://github.com/TanStack/query/blob/main/packages/preact-query/src/infiniteQueryOptions.ts#L233) You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`. @@ -159,13 +163,17 @@ function Comments({ postId }: { postId: string }) { queryClient.infiniteQuery(commentsOptions(postId)).catch(noop) ``` +### See + +[useInfiniteQuery](useInfiniteQuery.md) to run an infinite query with these options. + ## Call Signature ```ts function infiniteQueryOptions(options): UseInfiniteQueryOptions & object & QueryKeyWithDataTag, TError>; ``` -Defined in: [preact-query/src/infiniteQueryOptions.ts:306](https://github.com/TanStack/query/blob/main/packages/preact-query/src/infiniteQueryOptions.ts#L306) +Defined in: [preact-query/src/infiniteQueryOptions.ts:309](https://github.com/TanStack/query/blob/main/packages/preact-query/src/infiniteQueryOptions.ts#L309) You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`. @@ -247,3 +255,7 @@ function Comments({ postId }: { postId: string }) { // Elsewhere, e.g. to warm the cache before rendering ``: queryClient.infiniteQuery(commentsOptions(postId)).catch(noop) ``` + +### See + +[useInfiniteQuery](useInfiniteQuery.md) to run an infinite query with these options. diff --git a/docs/framework/preact/reference/functions/mutationOptions.md b/docs/framework/preact/reference/functions/mutationOptions.md index 66212f8e10..8d2e39f62a 100644 --- a/docs/framework/preact/reference/functions/mutationOptions.md +++ b/docs/framework/preact/reference/functions/mutationOptions.md @@ -9,7 +9,7 @@ title: mutationOptions function mutationOptions(options): WithRequired, "mutationKey">; ``` -Defined in: [preact-query/src/mutationOptions.ts:48](https://github.com/TanStack/query/blob/main/packages/preact-query/src/mutationOptions.ts#L48) +Defined in: [preact-query/src/mutationOptions.ts:49](https://github.com/TanStack/query/blob/main/packages/preact-query/src/mutationOptions.ts#L49) You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. A `mutationKey` is required on this overload so the mutation can be looked up later, e.g. with @@ -48,6 +48,10 @@ required `mutationKey`. The same options object, unchanged. +### See + +[useMutation](useMutation.md) to run the mutation these options describe. + ### Examples ```tsx @@ -88,7 +92,7 @@ function SavingIndicator() { function mutationOptions(options): Omit, "mutationKey">; ``` -Defined in: [preact-query/src/mutationOptions.ts:85](https://github.com/TanStack/query/blob/main/packages/preact-query/src/mutationOptions.ts#L85) +Defined in: [preact-query/src/mutationOptions.ts:87](https://github.com/TanStack/query/blob/main/packages/preact-query/src/mutationOptions.ts#L87) You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. No `mutationKey` is required on this overload — use this when you don't need to look the mutation up later @@ -127,6 +131,10 @@ The mutation options to use, identical to what you'd pass to `useMutation`, with The same options object, unchanged. +### See + +[useMutation](useMutation.md) to run the mutation these options describe. + ### Example ```tsx diff --git a/docs/framework/preact/reference/functions/queryOptions.md b/docs/framework/preact/reference/functions/queryOptions.md index f43effd12c..88e114030c 100644 --- a/docs/framework/preact/reference/functions/queryOptions.md +++ b/docs/framework/preact/reference/functions/queryOptions.md @@ -9,7 +9,7 @@ title: queryOptions function queryOptions(options): Omit, "queryFn"> & object & QueryKeyWithDataTag; ``` -Defined in: [preact-query/src/queryOptions.ts:130](https://github.com/TanStack/query/blob/main/packages/preact-query/src/queryOptions.ts#L130) +Defined in: [preact-query/src/queryOptions.ts:131](https://github.com/TanStack/query/blob/main/packages/preact-query/src/queryOptions.ts#L131) You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and @@ -47,6 +47,10 @@ The [DefinedInitialDataOptions](../type-aliases/DefinedInitialDataOptions.md) to The same options object, typed so that `queryKey` carries the inferred data type. +### See + +[useQuery](useQuery.md) to run a query with these options. + ### Example ```tsx @@ -71,7 +75,7 @@ function Posts() { function queryOptions(options): OmitKeyof, "queryFn"> & object & QueryKeyWithDataTag; ``` -Defined in: [preact-query/src/queryOptions.ts:199](https://github.com/TanStack/query/blob/main/packages/preact-query/src/queryOptions.ts#L199) +Defined in: [preact-query/src/queryOptions.ts:201](https://github.com/TanStack/query/blob/main/packages/preact-query/src/queryOptions.ts#L201) You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and @@ -107,6 +111,10 @@ The [UnusedSkipTokenOptions](../type-aliases/UnusedSkipTokenOptions.md) to use The same options object, typed so that `queryKey` carries the inferred data type. +### See + +[useQuery](useQuery.md) to run a query with these options. + ### Examples ```tsx @@ -163,7 +171,7 @@ queryClient.getQueryData(todosOptions.queryKey) // typed as Array | undefi function queryOptions(options): UseQueryOptions & object & QueryKeyWithDataTag; ``` -Defined in: [preact-query/src/queryOptions.ts:268](https://github.com/TanStack/query/blob/main/packages/preact-query/src/queryOptions.ts#L268) +Defined in: [preact-query/src/queryOptions.ts:271](https://github.com/TanStack/query/blob/main/packages/preact-query/src/queryOptions.ts#L271) You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and @@ -199,6 +207,10 @@ The [UndefinedInitialDataOptions](../type-aliases/UndefinedInitialDataOptions.md The same options object, typed so that `queryKey` carries the inferred data type. +### See + +[useQuery](useQuery.md) to run a query with these options. + ### Examples ```tsx diff --git a/docs/framework/preact/reference/functions/useInfiniteQuery.md b/docs/framework/preact/reference/functions/useInfiniteQuery.md index ebc08137b7..9c34fdeb49 100644 --- a/docs/framework/preact/reference/functions/useInfiniteQuery.md +++ b/docs/framework/preact/reference/functions/useInfiniteQuery.md @@ -9,7 +9,7 @@ title: useInfiniteQuery function useInfiniteQuery(options, queryClient?): DefinedUseInfiniteQueryResult; ``` -Defined in: [preact-query/src/useInfiniteQuery.ts:51](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useInfiniteQuery.ts#L51) +Defined in: [preact-query/src/useInfiniteQuery.ts:55](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useInfiniteQuery.ts#L55) The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `queryFn`, `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`. @@ -61,6 +61,16 @@ The same properties as `useQuery`, with the addition of `data.pages`, `data.page `fetchNextPage`, `fetchPreviousPage`, `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`. +### Remarks + +Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default +refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user +actions, or add conditions like `hasNextPage && !isFetching`. + +### See + +[infiniteQueryOptions](infiniteQueryOptions.md) to share these options between `useInfiniteQuery` and imperative APIs like `queryClient.infiniteQuery`. + ### Example ```tsx @@ -85,7 +95,7 @@ function Projects() { function useInfiniteQuery(options, queryClient?): UseInfiniteQueryResult; ``` -Defined in: [preact-query/src/useInfiniteQuery.ts:105](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useInfiniteQuery.ts#L105) +Defined in: [preact-query/src/useInfiniteQuery.ts:113](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useInfiniteQuery.ts#L113) The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `queryFn`, `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`. @@ -135,6 +145,16 @@ The same properties as `useQuery`, with the addition of `data.pages`, `data.page `fetchNextPage`, `fetchPreviousPage`, `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`. +### Remarks + +Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default +refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user +actions, or add conditions like `hasNextPage && !isFetching`. + +### See + +[infiniteQueryOptions](infiniteQueryOptions.md) to share these options between `useInfiniteQuery` and imperative APIs like `queryClient.infiniteQuery`. + ### Example ```tsx @@ -168,15 +188,11 @@ function Projects() { function useInfiniteQuery(options, queryClient?): UseInfiniteQueryResult; ``` -Defined in: [preact-query/src/useInfiniteQuery.ts:163](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useInfiniteQuery.ts#L163) +Defined in: [preact-query/src/useInfiniteQuery.ts:171](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useInfiniteQuery.ts#L171) The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `queryFn`, `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`. -Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default refetch -behavior, resulting in outdated data. Make sure to call these functions only in response to user actions, -or add conditions like `hasNextPage && !isFetching`. - ### Type Parameters #### TQueryFnData @@ -222,6 +238,16 @@ The same properties as `useQuery`, with the addition of `data.pages`, `data.page `fetchNextPage`, `fetchPreviousPage`, `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`. +### Remarks + +Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default +refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user +actions, or add conditions like `hasNextPage && !isFetching`. + +### See + +[infiniteQueryOptions](infiniteQueryOptions.md) to share these options between `useInfiniteQuery` and imperative APIs like `queryClient.infiniteQuery`. + ### Example ```tsx diff --git a/docs/framework/preact/reference/functions/useMutation.md b/docs/framework/preact/reference/functions/useMutation.md index a04d9c9328..db5f1f8eac 100644 --- a/docs/framework/preact/reference/functions/useMutation.md +++ b/docs/framework/preact/reference/functions/useMutation.md @@ -7,7 +7,7 @@ title: useMutation function useMutation(options, queryClient?): UseMutationResult; ``` -Defined in: [preact-query/src/useMutation.ts:86](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useMutation.ts#L86) +Defined in: [preact-query/src/useMutation.ts:87](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useMutation.ts#L87) Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects. `useMutation` is the hook for that. @@ -54,6 +54,10 @@ argument, useful for triggering call-site side effects (e.g. navigation) without mutation definition. If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +## See + +[mutationOptions](mutationOptions.md) to share these options across multiple `useMutation` call sites. + ## Examples ```tsx diff --git a/docs/framework/preact/reference/functions/useQuery.md b/docs/framework/preact/reference/functions/useQuery.md index 307464f120..0e50d558a6 100644 --- a/docs/framework/preact/reference/functions/useQuery.md +++ b/docs/framework/preact/reference/functions/useQuery.md @@ -9,7 +9,7 @@ title: useQuery function useQuery(options, queryClient?): DefinedUseQueryResult; ``` -Defined in: [preact-query/src/useQuery.ts:41](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQuery.ts#L41) +Defined in: [preact-query/src/useQuery.ts:42](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQuery.ts#L42) This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`. @@ -54,6 +54,10 @@ The current query result, typed so that `status` is `success` — or `error` if fails while keeping the existing data (`status` never resolves to `pending` in this overload's type, since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived booleans for convenience. +### See + +[queryOptions](queryOptions.md) to share these options between `useQuery` and imperative APIs like `queryClient.query`. + ### Example ```tsx @@ -77,7 +81,7 @@ function Posts() { function useQuery(options, queryClient?): UseQueryResult; ``` -Defined in: [preact-query/src/useQuery.ts:85](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQuery.ts#L85) +Defined in: [preact-query/src/useQuery.ts:87](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQuery.ts#L87) ### Type Parameters @@ -120,6 +124,10 @@ The current query result. `status` is `pending` if there is no cached data and n has finished yet, `error` if the query attempt resulted in an error, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError` are derived booleans for convenience. +### See + +[queryOptions](queryOptions.md) to share these options between `useQuery` and imperative APIs like `queryClient.query`. + ### Example ```tsx @@ -153,7 +161,7 @@ function Posts() { function useQuery(options, queryClient?): UseQueryResult; ``` -Defined in: [preact-query/src/useQuery.ts:166](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQuery.ts#L166) +Defined in: [preact-query/src/useQuery.ts:169](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQuery.ts#L169) ### Type Parameters @@ -196,6 +204,10 @@ The current query result. `status` is `pending` if there is no cached data and n has finished yet, `error` if the query attempt resulted in an error, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError` are derived booleans for convenience. +### See + +[queryOptions](queryOptions.md) to share these options between `useQuery` and imperative APIs like `queryClient.query`. + ### Examples ```tsx diff --git a/packages/preact-query/src/infiniteQueryOptions.ts b/packages/preact-query/src/infiniteQueryOptions.ts index 72d68a9248..bece80eeb6 100644 --- a/packages/preact-query/src/infiniteQueryOptions.ts +++ b/packages/preact-query/src/infiniteQueryOptions.ts @@ -132,6 +132,7 @@ export type DefinedInitialDataInfiniteOptions< * * This overload is selected when `initialData` is set. * + * @see {@link useInfiniteQuery} to run an infinite query with these options. * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData` set. * @returns The same options object, typed so that `queryKey` carries the inferred data type. * @@ -226,6 +227,7 @@ export function infiniteQueryOptions< * queryClient.infiniteQuery(commentsOptions(postId)).catch(noop) * ``` * + * @see {@link useInfiniteQuery} to run an infinite query with these options. * @param options - The {@link UnusedSkipTokenInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`. */ export function infiniteQueryOptions< @@ -301,6 +303,7 @@ export function infiniteQueryOptions< * queryClient.infiniteQuery(commentsOptions(postId)).catch(noop) * ``` * + * @see {@link useInfiniteQuery} to run an infinite query with these options. * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`. */ export function infiniteQueryOptions< diff --git a/packages/preact-query/src/mutationOptions.ts b/packages/preact-query/src/mutationOptions.ts index ffabea5a75..8763b4d903 100644 --- a/packages/preact-query/src/mutationOptions.ts +++ b/packages/preact-query/src/mutationOptions.ts @@ -7,6 +7,7 @@ import type { UseMutationOptions } from './types' * `mutationKey` is required on this overload so the mutation can be looked up later, e.g. with * `useMutationState`. * + * @see {@link useMutation} to run the mutation these options describe. * @param options - The mutation options to use, identical to what you'd pass to `useMutation`, with a * required `mutationKey`. * @returns The same options object, unchanged. @@ -64,6 +65,7 @@ export function mutationOptions< * `mutationKey` is required on this overload — use this when you don't need to look the mutation up later * (e.g. with `useMutationState`). * + * @see {@link useMutation} to run the mutation these options describe. * @param options - The mutation options to use, identical to what you'd pass to `useMutation`, without a * `mutationKey`. * @returns The same options object, unchanged. diff --git a/packages/preact-query/src/queryOptions.ts b/packages/preact-query/src/queryOptions.ts index 887a145ebb..440306fce4 100644 --- a/packages/preact-query/src/queryOptions.ts +++ b/packages/preact-query/src/queryOptions.ts @@ -107,6 +107,7 @@ export type DefinedInitialDataOptions< * * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`. * + * @see {@link useQuery} to run a query with these options. * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` set. * @returns The same options object, typed so that `queryKey` carries the inferred data type. * @@ -142,6 +143,7 @@ export function queryOptions< * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and * is the query key to generate options for. * + * @see {@link useQuery} to run a query with these options. * @param options - The {@link UnusedSkipTokenOptions} to use — everything you can pass to `useQuery`. * @returns The same options object, typed so that `queryKey` carries the inferred data type. * @@ -211,6 +213,7 @@ export function queryOptions< * be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and * is the query key to generate options for. * + * @see {@link useQuery} to run a query with these options. * @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `useQuery`. * @returns The same options object, typed so that `queryKey` carries the inferred data type. * diff --git a/packages/preact-query/src/useInfiniteQuery.ts b/packages/preact-query/src/useInfiniteQuery.ts index 95d2db3c02..44cb513c2f 100644 --- a/packages/preact-query/src/useInfiniteQuery.ts +++ b/packages/preact-query/src/useInfiniteQuery.ts @@ -24,6 +24,10 @@ import { useBaseQuery } from './useBaseQuery' * * This overload is selected when `initialData` is set. * + * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default + * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user + * actions, or add conditions like `hasNextPage && !isFetching`. + * @see {@link infiniteQueryOptions} to share these options between `useInfiniteQuery` and imperative APIs like `queryClient.infiniteQuery`. * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData` set. * @param queryClient - Use this to use a custom QueryClient. Otherwise, the one from the nearest context will * be used. @@ -69,6 +73,10 @@ export function useInfiniteQuery< * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `queryFn`, * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`. * + * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default + * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user + * actions, or add conditions like `hasNextPage && !isFetching`. + * @see {@link infiniteQueryOptions} to share these options between `useInfiniteQuery` and imperative APIs like `queryClient.infiniteQuery`. * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`. * @param queryClient - Use this to use a custom QueryClient. Otherwise, the one from the nearest context will * be used. @@ -123,10 +131,10 @@ export function useInfiniteQuery< * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `queryFn`, * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`. * - * Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default refetch - * behavior, resulting in outdated data. Make sure to call these functions only in response to user actions, - * or add conditions like `hasNextPage && !isFetching`. - * + * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default + * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user + * actions, or add conditions like `hasNextPage && !isFetching`. + * @see {@link infiniteQueryOptions} to share these options between `useInfiniteQuery` and imperative APIs like `queryClient.infiniteQuery`. * @param options - The {@link UseInfiniteQueryOptions} to use — everything you can pass to `useInfiniteQuery`. * @param queryClient - Use this to use a custom QueryClient. Otherwise, the one from the nearest context will * be used. diff --git a/packages/preact-query/src/useMutation.ts b/packages/preact-query/src/useMutation.ts index 23523885dc..a0df7aea83 100644 --- a/packages/preact-query/src/useMutation.ts +++ b/packages/preact-query/src/useMutation.ts @@ -21,6 +21,7 @@ import { useSyncExternalStore } from './utils' * Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects. * `useMutation` is the hook for that. * + * @see {@link mutationOptions} to share these options across multiple `useMutation` call sites. * @param options - The {@link UseMutationOptions} to use — everything you can pass to `useMutation`. * @param queryClient - Use this to use a custom QueryClient. Otherwise, the one from the nearest context will * be used. diff --git a/packages/preact-query/src/useQuery.ts b/packages/preact-query/src/useQuery.ts index 2c59c79f95..cbc4a7ef45 100644 --- a/packages/preact-query/src/useQuery.ts +++ b/packages/preact-query/src/useQuery.ts @@ -15,6 +15,7 @@ import { useBaseQuery } from './useBaseQuery' /** * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`. * + * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`. * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` set. * @param queryClient - Use this to use a custom QueryClient. Otherwise, the one from the nearest context will * be used. @@ -49,6 +50,7 @@ export function useQuery< ): DefinedUseQueryResult /** + * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`. * @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `useQuery`. * @param queryClient - Use this to use a custom QueryClient. Otherwise, the one from the nearest context will * be used. @@ -93,6 +95,7 @@ export function useQuery< ): UseQueryResult /** + * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`. * @param options - The {@link UseQueryOptions} to use — everything you can pass to `useQuery`. * @param queryClient - Use this to use a custom QueryClient. Otherwise, the one from the nearest context will * be used.