From 47fe85fedc2b1e829c67f7ec20636bfed5676903 Mon Sep 17 00:00:00 2001 From: Wonsuk Choi Date: Sun, 30 Aug 2026 13:21:44 +0900 Subject: [PATCH] docs(preact-query): inline the basic-query example's options instead of a 'queryOptions' factory --- .../preact/reference/functions/useQuery.md | 28 ++++++++----------- packages/preact-query/src/useQuery.ts | 24 +++++++--------- 2 files changed, 22 insertions(+), 30 deletions(-) diff --git a/docs/framework/preact/reference/functions/useQuery.md b/docs/framework/preact/reference/functions/useQuery.md index 4ce44660c4..99347676cd 100644 --- a/docs/framework/preact/reference/functions/useQuery.md +++ b/docs/framework/preact/reference/functions/useQuery.md @@ -89,7 +89,7 @@ function Posts() { function useQuery(options, queryClient?): UseQueryResult; ``` -Defined in: [preact-query/src/useQuery.ts:119](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQuery.ts#L119) +Defined in: [preact-query/src/useQuery.ts:117](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQuery.ts#L117) ### Type Parameters @@ -139,15 +139,13 @@ display. `isPending`/`isSuccess`/`isError` are derived booleans for convenience. ### Examples ```tsx -import { queryOptions, useQuery } from '@tanstack/preact-query' - -const postsOptions = queryOptions({ - queryKey: ['posts'], - queryFn: fetchPosts, -}) +import { useQuery } from '@tanstack/preact-query' function Posts() { - const { status, data, error, isFetching } = useQuery(postsOptions) + const { status, data, error, isFetching } = useQuery({ + queryKey: ['posts'], + queryFn: fetchPosts, + }) if (status === 'pending') return 'Loading...' if (status === 'error') return Error: {error.message} @@ -192,7 +190,7 @@ function Posts() { function useQuery(options, queryClient?): UseQueryResult; ``` -Defined in: [preact-query/src/useQuery.ts:297](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQuery.ts#L297) +Defined in: [preact-query/src/useQuery.ts:293](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQuery.ts#L293) ### Type Parameters @@ -242,15 +240,13 @@ display. `isPending`/`isSuccess`/`isError` are derived booleans for convenience. ### Examples ```tsx -import { queryOptions, useQuery } from '@tanstack/preact-query' - -const postsOptions = queryOptions({ - queryKey: ['posts'], - queryFn: fetchPosts, -}) +import { useQuery } from '@tanstack/preact-query' function Posts() { - const { status, data, error, isFetching } = useQuery(postsOptions) + const { status, data, error, isFetching } = useQuery({ + queryKey: ['posts'], + queryFn: fetchPosts, + }) if (status === 'pending') return 'Loading...' if (status === 'error') return Error: {error.message} diff --git a/packages/preact-query/src/useQuery.ts b/packages/preact-query/src/useQuery.ts index e005fe2f54..72f957016a 100644 --- a/packages/preact-query/src/useQuery.ts +++ b/packages/preact-query/src/useQuery.ts @@ -68,15 +68,13 @@ export function useQuery< * * @example * ```tsx - * import { queryOptions, useQuery } from '@tanstack/preact-query' - * - * const postsOptions = queryOptions({ - * queryKey: ['posts'], - * queryFn: fetchPosts, - * }) + * import { useQuery } from '@tanstack/preact-query' * * function Posts() { - * const { status, data, error, isFetching } = useQuery(postsOptions) + * const { status, data, error, isFetching } = useQuery({ + * queryKey: ['posts'], + * queryFn: fetchPosts, + * }) * * if (status === 'pending') return 'Loading...' * if (status === 'error') return Error: {error.message} @@ -137,15 +135,13 @@ export function useQuery< * * @example * ```tsx - * import { queryOptions, useQuery } from '@tanstack/preact-query' - * - * const postsOptions = queryOptions({ - * queryKey: ['posts'], - * queryFn: fetchPosts, - * }) + * import { useQuery } from '@tanstack/preact-query' * * function Posts() { - * const { status, data, error, isFetching } = useQuery(postsOptions) + * const { status, data, error, isFetching } = useQuery({ + * queryKey: ['posts'], + * queryFn: fetchPosts, + * }) * * if (status === 'pending') return 'Loading...' * if (status === 'error') return Error: {error.message}