@tanstack/react-query 5.105.0 → 5.105.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/legacy/HydrationBoundary.cjs +2 -3
- package/build/legacy/HydrationBoundary.d.cts +0 -2
- package/build/legacy/HydrationBoundary.d.cts.map +1 -1
- package/build/legacy/HydrationBoundary.d.ts +0 -2
- package/build/legacy/HydrationBoundary.d.ts.map +1 -1
- package/build/legacy/HydrationBoundary.js +1 -2
- package/build/legacy/IsRestoringProvider.cjs +2 -3
- package/build/legacy/IsRestoringProvider.d.cts +0 -2
- package/build/legacy/IsRestoringProvider.d.cts.map +1 -1
- package/build/legacy/IsRestoringProvider.d.ts +0 -2
- package/build/legacy/IsRestoringProvider.d.ts.map +1 -1
- package/build/legacy/IsRestoringProvider.js +1 -2
- package/build/legacy/QueryClientProvider.cjs +2 -3
- package/build/legacy/QueryClientProvider.d.cts +0 -2
- package/build/legacy/QueryClientProvider.d.cts.map +1 -1
- package/build/legacy/QueryClientProvider.d.ts +0 -2
- package/build/legacy/QueryClientProvider.d.ts.map +1 -1
- package/build/legacy/QueryClientProvider.js +1 -2
- package/build/legacy/QueryErrorResetBoundary.cjs +2 -3
- package/build/legacy/QueryErrorResetBoundary.d.cts +1 -3
- package/build/legacy/QueryErrorResetBoundary.d.cts.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.d.ts +1 -3
- package/build/legacy/QueryErrorResetBoundary.d.ts.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.js +1 -2
- package/build/legacy/errorBoundaryUtils.cjs +2 -3
- package/build/legacy/errorBoundaryUtils.d.cts +0 -2
- package/build/legacy/errorBoundaryUtils.d.cts.map +1 -1
- package/build/legacy/errorBoundaryUtils.d.ts +0 -2
- package/build/legacy/errorBoundaryUtils.d.ts.map +1 -1
- package/build/legacy/errorBoundaryUtils.js +1 -2
- package/build/legacy/index.cjs +1 -2
- package/build/legacy/index.js +1 -2
- package/build/legacy/infiniteQueryOptions.cjs +1 -2
- package/build/legacy/infiniteQueryOptions.cjs.map +1 -1
- package/build/legacy/infiniteQueryOptions.d.cts +16 -16
- package/build/legacy/infiniteQueryOptions.d.cts.map +1 -1
- package/build/legacy/infiniteQueryOptions.d.ts +16 -16
- package/build/legacy/infiniteQueryOptions.d.ts.map +1 -1
- package/build/legacy/infiniteQueryOptions.js +1 -2
- package/build/legacy/infiniteQueryOptions.js.map +1 -1
- package/build/legacy/mutationOptions.cjs +1 -2
- package/build/legacy/mutationOptions.d.cts +0 -2
- package/build/legacy/mutationOptions.d.cts.map +1 -1
- package/build/legacy/mutationOptions.d.ts +0 -2
- package/build/legacy/mutationOptions.d.ts.map +1 -1
- package/build/legacy/mutationOptions.js +1 -2
- package/build/legacy/queryOptions.cjs +1 -2
- package/build/legacy/queryOptions.cjs.map +1 -1
- package/build/legacy/queryOptions.d.cts +16 -15
- package/build/legacy/queryOptions.d.cts.map +1 -1
- package/build/legacy/queryOptions.d.ts +16 -15
- package/build/legacy/queryOptions.d.ts.map +1 -1
- package/build/legacy/queryOptions.js +1 -2
- package/build/legacy/queryOptions.js.map +1 -1
- package/build/legacy/{rolldown-runtime-VH7oDXx4.cjs → rolldown-runtime-CmQyd0Gu.cjs} +1 -2
- package/build/legacy/suspense.cjs +1 -2
- package/build/legacy/suspense.d.cts +0 -2
- package/build/legacy/suspense.d.cts.map +1 -1
- package/build/legacy/suspense.d.ts +0 -2
- package/build/legacy/suspense.d.ts.map +1 -1
- package/build/legacy/suspense.js +1 -2
- package/build/legacy/types.cjs +1 -2
- package/build/legacy/types.d.cts +0 -2
- package/build/legacy/types.d.cts.map +1 -1
- package/build/legacy/types.d.ts +0 -2
- package/build/legacy/types.d.ts.map +1 -1
- package/build/legacy/types.js +1 -2
- package/build/legacy/useBaseQuery.cjs +2 -3
- package/build/legacy/useBaseQuery.d.cts +0 -2
- package/build/legacy/useBaseQuery.d.cts.map +1 -1
- package/build/legacy/useBaseQuery.d.ts +0 -2
- package/build/legacy/useBaseQuery.d.ts.map +1 -1
- package/build/legacy/useBaseQuery.js +1 -2
- package/build/legacy/useInfiniteQuery.cjs +1 -2
- package/build/legacy/useInfiniteQuery.cjs.map +1 -1
- package/build/legacy/useInfiniteQuery.d.cts +2 -4
- package/build/legacy/useInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/useInfiniteQuery.d.ts +2 -4
- package/build/legacy/useInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/useInfiniteQuery.js +1 -2
- package/build/legacy/useInfiniteQuery.js.map +1 -1
- package/build/legacy/useIsFetching.cjs +2 -3
- package/build/legacy/useIsFetching.cjs.map +1 -1
- package/build/legacy/useIsFetching.d.cts +1 -3
- package/build/legacy/useIsFetching.d.cts.map +1 -1
- package/build/legacy/useIsFetching.d.ts +1 -3
- package/build/legacy/useIsFetching.d.ts.map +1 -1
- package/build/legacy/useIsFetching.js +1 -2
- package/build/legacy/useIsFetching.js.map +1 -1
- package/build/legacy/useMutation.cjs +2 -3
- package/build/legacy/useMutation.d.cts +0 -2
- package/build/legacy/useMutation.d.cts.map +1 -1
- package/build/legacy/useMutation.d.ts +0 -2
- package/build/legacy/useMutation.d.ts.map +1 -1
- package/build/legacy/useMutation.js +1 -2
- package/build/legacy/useMutationState.cjs +2 -3
- package/build/legacy/useMutationState.d.cts +0 -2
- package/build/legacy/useMutationState.d.cts.map +1 -1
- package/build/legacy/useMutationState.d.ts +0 -2
- package/build/legacy/useMutationState.d.ts.map +1 -1
- package/build/legacy/useMutationState.js +1 -2
- package/build/legacy/usePrefetchInfiniteQuery.cjs +1 -2
- package/build/legacy/usePrefetchInfiniteQuery.d.cts +0 -2
- package/build/legacy/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.ts +0 -2
- package/build/legacy/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.js +1 -2
- package/build/legacy/usePrefetchQuery.cjs +1 -2
- package/build/legacy/usePrefetchQuery.d.cts +0 -2
- package/build/legacy/usePrefetchQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchQuery.d.ts +0 -2
- package/build/legacy/usePrefetchQuery.d.ts.map +1 -1
- package/build/legacy/usePrefetchQuery.js +1 -2
- package/build/legacy/useQueries.cjs +2 -3
- package/build/legacy/useQueries.d.cts +0 -2
- package/build/legacy/useQueries.d.cts.map +1 -1
- package/build/legacy/useQueries.d.ts +0 -2
- package/build/legacy/useQueries.d.ts.map +1 -1
- package/build/legacy/useQueries.js +1 -2
- package/build/legacy/useQuery.cjs +1 -2
- package/build/legacy/useQuery.cjs.map +1 -1
- package/build/legacy/useQuery.d.cts +5 -7
- package/build/legacy/useQuery.d.cts.map +1 -1
- package/build/legacy/useQuery.d.ts +5 -7
- package/build/legacy/useQuery.d.ts.map +1 -1
- package/build/legacy/useQuery.js +1 -2
- package/build/legacy/useQuery.js.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.cjs +1 -2
- package/build/legacy/useSuspenseInfiniteQuery.d.cts +0 -2
- package/build/legacy/useSuspenseInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.d.ts +0 -2
- package/build/legacy/useSuspenseInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.js +1 -2
- package/build/legacy/useSuspenseQueries.cjs +1 -2
- package/build/legacy/useSuspenseQueries.d.cts +0 -2
- package/build/legacy/useSuspenseQueries.d.cts.map +1 -1
- package/build/legacy/useSuspenseQueries.d.ts +0 -2
- package/build/legacy/useSuspenseQueries.d.ts.map +1 -1
- package/build/legacy/useSuspenseQueries.js +1 -2
- package/build/legacy/useSuspenseQuery.cjs +1 -2
- package/build/legacy/useSuspenseQuery.d.cts +0 -2
- package/build/legacy/useSuspenseQuery.d.cts.map +1 -1
- package/build/legacy/useSuspenseQuery.d.ts +0 -2
- package/build/legacy/useSuspenseQuery.d.ts.map +1 -1
- package/build/legacy/useSuspenseQuery.js +1 -2
- package/build/modern/HydrationBoundary.cjs +2 -3
- package/build/modern/HydrationBoundary.d.cts +0 -2
- package/build/modern/HydrationBoundary.d.cts.map +1 -1
- package/build/modern/HydrationBoundary.d.ts +0 -2
- package/build/modern/HydrationBoundary.d.ts.map +1 -1
- package/build/modern/HydrationBoundary.js +1 -2
- package/build/modern/IsRestoringProvider.cjs +2 -3
- package/build/modern/IsRestoringProvider.d.cts +0 -2
- package/build/modern/IsRestoringProvider.d.cts.map +1 -1
- package/build/modern/IsRestoringProvider.d.ts +0 -2
- package/build/modern/IsRestoringProvider.d.ts.map +1 -1
- package/build/modern/IsRestoringProvider.js +1 -2
- package/build/modern/QueryClientProvider.cjs +2 -3
- package/build/modern/QueryClientProvider.d.cts +0 -2
- package/build/modern/QueryClientProvider.d.cts.map +1 -1
- package/build/modern/QueryClientProvider.d.ts +0 -2
- package/build/modern/QueryClientProvider.d.ts.map +1 -1
- package/build/modern/QueryClientProvider.js +1 -2
- package/build/modern/QueryErrorResetBoundary.cjs +2 -3
- package/build/modern/QueryErrorResetBoundary.d.cts +1 -3
- package/build/modern/QueryErrorResetBoundary.d.cts.map +1 -1
- package/build/modern/QueryErrorResetBoundary.d.ts +1 -3
- package/build/modern/QueryErrorResetBoundary.d.ts.map +1 -1
- package/build/modern/QueryErrorResetBoundary.js +1 -2
- package/build/modern/errorBoundaryUtils.cjs +2 -3
- package/build/modern/errorBoundaryUtils.d.cts +0 -2
- package/build/modern/errorBoundaryUtils.d.cts.map +1 -1
- package/build/modern/errorBoundaryUtils.d.ts +0 -2
- package/build/modern/errorBoundaryUtils.d.ts.map +1 -1
- package/build/modern/errorBoundaryUtils.js +1 -2
- package/build/modern/index.cjs +1 -2
- package/build/modern/index.js +1 -2
- package/build/modern/infiniteQueryOptions.cjs +1 -2
- package/build/modern/infiniteQueryOptions.cjs.map +1 -1
- package/build/modern/infiniteQueryOptions.d.cts +16 -16
- package/build/modern/infiniteQueryOptions.d.cts.map +1 -1
- package/build/modern/infiniteQueryOptions.d.ts +16 -16
- package/build/modern/infiniteQueryOptions.d.ts.map +1 -1
- package/build/modern/infiniteQueryOptions.js +1 -2
- package/build/modern/infiniteQueryOptions.js.map +1 -1
- package/build/modern/mutationOptions.cjs +1 -2
- package/build/modern/mutationOptions.d.cts +0 -2
- package/build/modern/mutationOptions.d.cts.map +1 -1
- package/build/modern/mutationOptions.d.ts +0 -2
- package/build/modern/mutationOptions.d.ts.map +1 -1
- package/build/modern/mutationOptions.js +1 -2
- package/build/modern/queryOptions.cjs +1 -2
- package/build/modern/queryOptions.cjs.map +1 -1
- package/build/modern/queryOptions.d.cts +16 -15
- package/build/modern/queryOptions.d.cts.map +1 -1
- package/build/modern/queryOptions.d.ts +16 -15
- package/build/modern/queryOptions.d.ts.map +1 -1
- package/build/modern/queryOptions.js +1 -2
- package/build/modern/queryOptions.js.map +1 -1
- package/build/modern/{rolldown-runtime-VH7oDXx4.cjs → rolldown-runtime-CmQyd0Gu.cjs} +1 -2
- package/build/modern/suspense.cjs +1 -2
- package/build/modern/suspense.d.cts +0 -2
- package/build/modern/suspense.d.cts.map +1 -1
- package/build/modern/suspense.d.ts +0 -2
- package/build/modern/suspense.d.ts.map +1 -1
- package/build/modern/suspense.js +1 -2
- package/build/modern/types.cjs +1 -2
- package/build/modern/types.d.cts +0 -2
- package/build/modern/types.d.cts.map +1 -1
- package/build/modern/types.d.ts +0 -2
- package/build/modern/types.d.ts.map +1 -1
- package/build/modern/types.js +1 -2
- package/build/modern/useBaseQuery.cjs +2 -3
- package/build/modern/useBaseQuery.d.cts +0 -2
- package/build/modern/useBaseQuery.d.cts.map +1 -1
- package/build/modern/useBaseQuery.d.ts +0 -2
- package/build/modern/useBaseQuery.d.ts.map +1 -1
- package/build/modern/useBaseQuery.js +1 -2
- package/build/modern/useInfiniteQuery.cjs +1 -2
- package/build/modern/useInfiniteQuery.cjs.map +1 -1
- package/build/modern/useInfiniteQuery.d.cts +2 -4
- package/build/modern/useInfiniteQuery.d.cts.map +1 -1
- package/build/modern/useInfiniteQuery.d.ts +2 -4
- package/build/modern/useInfiniteQuery.d.ts.map +1 -1
- package/build/modern/useInfiniteQuery.js +1 -2
- package/build/modern/useInfiniteQuery.js.map +1 -1
- package/build/modern/useIsFetching.cjs +2 -3
- package/build/modern/useIsFetching.cjs.map +1 -1
- package/build/modern/useIsFetching.d.cts +1 -3
- package/build/modern/useIsFetching.d.cts.map +1 -1
- package/build/modern/useIsFetching.d.ts +1 -3
- package/build/modern/useIsFetching.d.ts.map +1 -1
- package/build/modern/useIsFetching.js +1 -2
- package/build/modern/useIsFetching.js.map +1 -1
- package/build/modern/useMutation.cjs +2 -3
- package/build/modern/useMutation.d.cts +0 -2
- package/build/modern/useMutation.d.cts.map +1 -1
- package/build/modern/useMutation.d.ts +0 -2
- package/build/modern/useMutation.d.ts.map +1 -1
- package/build/modern/useMutation.js +1 -2
- package/build/modern/useMutationState.cjs +2 -3
- package/build/modern/useMutationState.d.cts +0 -2
- package/build/modern/useMutationState.d.cts.map +1 -1
- package/build/modern/useMutationState.d.ts +0 -2
- package/build/modern/useMutationState.d.ts.map +1 -1
- package/build/modern/useMutationState.js +1 -2
- package/build/modern/usePrefetchInfiniteQuery.cjs +1 -2
- package/build/modern/usePrefetchInfiniteQuery.d.cts +0 -2
- package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.ts +0 -2
- package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.js +1 -2
- package/build/modern/usePrefetchQuery.cjs +1 -2
- package/build/modern/usePrefetchQuery.d.cts +0 -2
- package/build/modern/usePrefetchQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchQuery.d.ts +0 -2
- package/build/modern/usePrefetchQuery.d.ts.map +1 -1
- package/build/modern/usePrefetchQuery.js +1 -2
- package/build/modern/useQueries.cjs +2 -3
- package/build/modern/useQueries.d.cts +0 -2
- package/build/modern/useQueries.d.cts.map +1 -1
- package/build/modern/useQueries.d.ts +0 -2
- package/build/modern/useQueries.d.ts.map +1 -1
- package/build/modern/useQueries.js +1 -2
- package/build/modern/useQuery.cjs +1 -2
- package/build/modern/useQuery.cjs.map +1 -1
- package/build/modern/useQuery.d.cts +5 -7
- package/build/modern/useQuery.d.cts.map +1 -1
- package/build/modern/useQuery.d.ts +5 -7
- package/build/modern/useQuery.d.ts.map +1 -1
- package/build/modern/useQuery.js +1 -2
- package/build/modern/useQuery.js.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.cjs +1 -2
- package/build/modern/useSuspenseInfiniteQuery.d.cts +0 -2
- package/build/modern/useSuspenseInfiniteQuery.d.cts.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.d.ts +0 -2
- package/build/modern/useSuspenseInfiniteQuery.d.ts.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.js +1 -2
- package/build/modern/useSuspenseQueries.cjs +1 -2
- package/build/modern/useSuspenseQueries.d.cts +0 -2
- package/build/modern/useSuspenseQueries.d.cts.map +1 -1
- package/build/modern/useSuspenseQueries.d.ts +0 -2
- package/build/modern/useSuspenseQueries.d.ts.map +1 -1
- package/build/modern/useSuspenseQueries.js +1 -2
- package/build/modern/useSuspenseQuery.cjs +1 -2
- package/build/modern/useSuspenseQuery.d.cts +0 -2
- package/build/modern/useSuspenseQuery.d.cts.map +1 -1
- package/build/modern/useSuspenseQuery.d.ts +0 -2
- package/build/modern/useSuspenseQuery.d.ts.map +1 -1
- package/build/modern/useSuspenseQuery.js +1 -2
- package/package.json +8 -8
- package/src/infiniteQueryOptions.ts +15 -14
- package/src/queryOptions.ts +16 -13
- package/src/useInfiniteQuery.ts +2 -2
- package/src/useIsFetching.ts +1 -1
- package/src/useQuery.ts +5 -5
package/build/modern/useQuery.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useBaseQuery } from "./useBaseQuery.js";
|
|
3
3
|
import { QueryObserver } from "@tanstack/query-core";
|
|
4
|
-
|
|
4
|
+
// src/useQuery.ts
|
|
5
5
|
function useQuery(options, queryClient) {
|
|
6
6
|
return useBaseQuery(options, QueryObserver, queryClient);
|
|
7
7
|
}
|
|
8
|
-
//#endregion
|
|
9
8
|
export { useQuery };
|
|
10
9
|
|
|
11
10
|
//# sourceMappingURL=useQuery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuery.js","names":[],"sources":["../../src/useQuery.ts"],"sourcesContent":["'use client'\nimport { QueryObserver } from '@tanstack/query-core'\nimport { useBaseQuery } from './useBaseQuery'\nimport type { DefaultError, QueryClient, QueryKey } from '@tanstack/query-core'\nimport type {\n DefinedUseQueryResult,\n UseQueryOptions,\n UseQueryResult,\n} from './types'\nimport type {\n DefinedInitialDataOptions,\n UndefinedInitialDataOptions,\n} from './queryOptions'\n\n/**\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless\n * a `select` changes `TData` to include `undefined`).\n * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` set.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns The current query result, typed so that `status` is `success` — or `error` if a fetch attempt\n * fails while keeping the existing data (`status` never resolves to `pending` in this overload's type,\n * since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived booleans for convenience.\n * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.\n * @example\n * ```tsx\n * import { useQuery } from '@tanstack/react-query'\n *\n * function Posts() {\n * // `data` is `Post[]`, never `undefined`, thanks to `initialData` — even if a refetch fails,\n * // so the list stays visible alongside the error.\n * const { data, isError, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n *\n * return (\n * <div>\n * {isError ? <span>Error: {error.message}</span> : null}\n * <ul>\n * {data.map((post) => <li key={post.id}>{post.title}</li>)}\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): DefinedUseQueryResult<TData, TError>\n\n/**\n * This overload is selected when `initialData` is omitted or may be `undefined`, so the resulting `data`\n * can be `undefined`.\n * @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `useQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if\n * the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError`\n * are derived booleans for convenience.\n * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.\n * @example\n * ```tsx\n * import { useQuery } from '@tanstack/react-query'\n *\n * function Posts() {\n * const { status, data, error, isFetching } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * })\n *\n * if (status === 'pending') return 'Loading...'\n * if (status === 'error') return <span>Error: {error.message}</span>\n *\n * return (\n * <div>\n * <ul>\n * {data.map((post) => (\n * <li key={post.id}>{post.title}</li>\n * ))}\n * </ul>\n * <div>{isFetching ? 'Background Updating...' : ' '}</div>\n * </div>\n * )\n * }\n * ```\n * @example\n * The same query, checking `isPending`/`isError` instead of `status` — pick whichever reads better to you:\n * ```tsx\n * import { useQuery } from '@tanstack/react-query'\n *\n * function Posts() {\n * const { isPending, isError, data, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * })\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return (\n * <ul>\n * {data.map((post) => <li key={post.id}>{post.title}</li>)}\n * </ul>\n * )\n * }\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): UseQueryResult<TData, TError>\n\n/**\n * Fallback overload for options whose `initialData` presence isn't statically known — for example, an\n * object typed as {@link UseQueryOptions} rather than an object literal. Prefer one of the other overloads\n * when possible, since they infer whether `data` can be `undefined` from `initialData` directly.\n * @param options - The {@link UseQueryOptions} to use — everything you can pass to `useQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if\n * the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError`\n * are derived booleans for convenience.\n * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.\n * @example\n * ```tsx\n * import { useQuery } from '@tanstack/react-query'\n *\n * function Posts() {\n * const { status, data, error, isFetching } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * })\n *\n * if (status === 'pending') return 'Loading...'\n * if (status === 'error') return <span>Error: {error.message}</span>\n *\n * return (\n * <div>\n * <ul>\n * {data.map((post) => (\n * <li key={post.id}>{post.title}</li>\n * ))}\n * </ul>\n * <div>{isFetching ? 'Background Updating...' : ' '}</div>\n * </div>\n * )\n * }\n * ```\n * @example\n * `select` derives whatever `data` a component needs from the cached value, without changing what's\n * actually stored in the cache — the cache still holds the full `Post[]`, but `data` here is a `number`:\n * ```tsx\n * import { useQuery } from '@tanstack/react-query'\n *\n * function PostCount() {\n * const { data, isPending, isError, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * select: (posts) => posts.length,\n * })\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <span>{data} posts</span>\n * }\n * ```\n * @example\n * A dependent query, only enabled once `postId` is set — use `isLoading`, not `isPending`, so the\n * loading state doesn't show while the query is disabled:\n * ```tsx\n * import { useQuery } from '@tanstack/react-query'\n *\n * function Post({ postId }: { postId: number | undefined }) {\n * const { data, isLoading, isError, error } = useQuery({\n * queryKey: ['post', postId],\n * queryFn: () => fetchPost(postId!),\n * enabled: postId != null,\n * })\n *\n * if (postId == null) return 'Select a post'\n * if (isLoading) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data?.title}</h1>\n * }\n * ```\n * @example\n * The same dependent query, type safe: `skipToken` disables the query without needing the\n * non-null assertion above, since `queryFn` is only ever called when `postId` is defined.\n * `refetch` doesn't work while `queryFn` is `skipToken` — use `enabled: false` instead if you\n * need to trigger the query manually:\n * ```tsx\n * import { skipToken, useQuery } from '@tanstack/react-query'\n *\n * function Post({ postId }: { postId: number | undefined }) {\n * const { data, isLoading, isError, error } = useQuery({\n * queryKey: ['post', postId],\n * queryFn: postId != null ? () => fetchPost(postId) : skipToken,\n * })\n *\n * if (postId == null) return 'Select a post'\n * if (isLoading) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data?.title}</h1>\n * }\n * ```\n * @example\n * Seeding a detail query from an already-cached list, to skip the loading state. `initialDataUpdatedAt` carries\n * over the list's own fetch time, so that if you set a `staleTime`, it's measured from when the list was\n * fetched rather than from now:\n * ```tsx\n * import { useQuery, useQueryClient } from '@tanstack/react-query'\n *\n * function Post({ postId }: { postId: number }) {\n * const queryClient = useQueryClient()\n *\n * const { data, isError, error } = useQuery({\n * queryKey: ['post', postId],\n * queryFn: () => fetchPost(postId),\n * initialData: () =>\n * queryClient\n * .getQueryData<Array<Post>>(['posts'])\n * ?.find((post) => post.id === postId),\n * initialDataUpdatedAt: () =>\n * queryClient.getQueryState(['posts'])?.dataUpdatedAt,\n * })\n *\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data?.title}</h1>\n * }\n * ```\n * @example\n * Paginated data, keeping the previous page's data visible while the next page loads:\n * ```tsx\n * import { keepPreviousData, useQuery } from '@tanstack/react-query'\n * import { useState } from 'react'\n *\n * function Posts() {\n * const [page, setPage] = useState(0)\n *\n * const { data, isPlaceholderData, isError, error } = useQuery({\n * queryKey: ['posts', page],\n * queryFn: () => fetchPosts(page),\n * placeholderData: keepPreviousData,\n * })\n *\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return (\n * <div>\n * <ul>\n * {data?.map((post) => <li key={post.id}>{post.title}</li>)}\n * </ul>\n * <button\n * disabled={isPlaceholderData}\n * onClick={() => setPage((old) => old + 1)}\n * >\n * Next Page\n * </button>\n * </div>\n * )\n * }\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): UseQueryResult<TData, TError>\n\nexport function useQuery(options: UseQueryOptions, queryClient?: QueryClient) {\n return useBaseQuery(options, QueryObserver, queryClient)\n}\n"],"mappings":";;;;AAkSA,SAAgB,SAAS,SAA0B,aAA2B;CAC5E,OAAO,aAAa,SAAS,eAAe,WAAW;AACzD"}
|
|
1
|
+
{"version":3,"file":"useQuery.js","names":[],"sources":["../../src/useQuery.ts"],"sourcesContent":["'use client'\nimport { QueryObserver } from '@tanstack/query-core'\nimport { useBaseQuery } from './useBaseQuery'\nimport type { DefaultError, QueryClient, QueryKey } from '@tanstack/query-core'\nimport type {\n DefinedUseQueryResult,\n UseQueryOptions,\n UseQueryResult,\n} from './types'\nimport type {\n DefinedInitialDataOptions,\n UndefinedInitialDataOptions,\n} from './queryOptions'\n\n/**\n * This overload is selected when `initialData` is known to be defined, so the resulting `data` is never\n * `undefined` (unless a `select` changes `TData` to include `undefined`).\n * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` known to be defined.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns The current query result, typed so that `status` is `success` — or `error` if a fetch attempt\n * fails while keeping the existing data (`status` never resolves to `pending` in this overload's type,\n * since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived booleans for convenience.\n * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.\n * @example\n * ```tsx\n * import { useQuery } from '@tanstack/react-query'\n *\n * function Posts() {\n * // `data` is `Post[]`, never `undefined`, thanks to `initialData` — even if a refetch fails,\n * // so the list stays visible alongside the error.\n * const { data, isError, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n *\n * return (\n * <div>\n * {isError ? <span>Error: {error.message}</span> : null}\n * <ul>\n * {data.map((post) => <li key={post.id}>{post.title}</li>)}\n * </ul>\n * </div>\n * )\n * }\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): DefinedUseQueryResult<TData, TError>\n\n/**\n * This overload is selected when `initialData` is omitted, may be `undefined`, or is a function that may\n * return `undefined`, so the resulting `data` can be `undefined`.\n * @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `useQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if\n * the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError`\n * are derived booleans for convenience.\n * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.\n * @example\n * ```tsx\n * import { useQuery } from '@tanstack/react-query'\n *\n * function Posts() {\n * const { status, data, error, isFetching } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * })\n *\n * if (status === 'pending') return 'Loading...'\n * if (status === 'error') return <span>Error: {error.message}</span>\n *\n * return (\n * <div>\n * <ul>\n * {data.map((post) => (\n * <li key={post.id}>{post.title}</li>\n * ))}\n * </ul>\n * <div>{isFetching ? 'Background Updating...' : ' '}</div>\n * </div>\n * )\n * }\n * ```\n * @example\n * The same query, checking `isPending`/`isError` instead of `status` — pick whichever reads better to you:\n * ```tsx\n * import { useQuery } from '@tanstack/react-query'\n *\n * function Posts() {\n * const { isPending, isError, data, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * })\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return (\n * <ul>\n * {data.map((post) => <li key={post.id}>{post.title}</li>)}\n * </ul>\n * )\n * }\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): UseQueryResult<TData, TError>\n\n/**\n * Fallback overload for options whose `initialData` presence isn't statically known — for example, an\n * object typed as {@link UseQueryOptions} rather than an object literal. Prefer one of the other overloads\n * when possible, since they infer whether `data` can be `undefined` from `initialData` directly.\n * @param options - The {@link UseQueryOptions} to use — everything you can pass to `useQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns The current query result. `status` is `pending` if there is no cached data to display, `error` if\n * the last fetch attempt failed, or `success` if the query has data to display. `isPending`/`isSuccess`/`isError`\n * are derived booleans for convenience.\n * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.\n * @example\n * ```tsx\n * import { useQuery } from '@tanstack/react-query'\n *\n * function Posts() {\n * const { status, data, error, isFetching } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * })\n *\n * if (status === 'pending') return 'Loading...'\n * if (status === 'error') return <span>Error: {error.message}</span>\n *\n * return (\n * <div>\n * <ul>\n * {data.map((post) => (\n * <li key={post.id}>{post.title}</li>\n * ))}\n * </ul>\n * <div>{isFetching ? 'Background Updating...' : ' '}</div>\n * </div>\n * )\n * }\n * ```\n * @example\n * `select` derives whatever `data` a component needs from the cached value, without changing what's\n * actually stored in the cache — the cache still holds the full `Post[]`, but `data` here is a `number`:\n * ```tsx\n * import { useQuery } from '@tanstack/react-query'\n *\n * function PostCount() {\n * const { data, isPending, isError, error } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * select: (posts) => posts.length,\n * })\n *\n * if (isPending) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <span>{data} posts</span>\n * }\n * ```\n * @example\n * A dependent query, only enabled once `postId` is set — use `isLoading`, not `isPending`, so the\n * loading state doesn't show while the query is disabled:\n * ```tsx\n * import { useQuery } from '@tanstack/react-query'\n *\n * function Post({ postId }: { postId: number | undefined }) {\n * const { data, isLoading, isError, error } = useQuery({\n * queryKey: ['post', postId],\n * queryFn: () => fetchPost(postId!),\n * enabled: postId != null,\n * })\n *\n * if (postId == null) return 'Select a post'\n * if (isLoading) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data?.title}</h1>\n * }\n * ```\n * @example\n * The same dependent query, type safe: `skipToken` disables the query without needing the\n * non-null assertion above, since `queryFn` is only ever called when `postId` is defined.\n * `refetch` doesn't work while `queryFn` is `skipToken` — use `enabled: false` instead if you\n * need to trigger the query manually:\n * ```tsx\n * import { skipToken, useQuery } from '@tanstack/react-query'\n *\n * function Post({ postId }: { postId: number | undefined }) {\n * const { data, isLoading, isError, error } = useQuery({\n * queryKey: ['post', postId],\n * queryFn: postId != null ? () => fetchPost(postId) : skipToken,\n * })\n *\n * if (postId == null) return 'Select a post'\n * if (isLoading) return 'Loading...'\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data?.title}</h1>\n * }\n * ```\n * @example\n * Seeding a detail query from an already-cached list, to skip the loading state. `initialDataUpdatedAt` carries\n * over the list's own fetch time, so that if you set a `staleTime`, it's measured from when the list was\n * fetched rather than from now:\n * ```tsx\n * import { useQuery, useQueryClient } from '@tanstack/react-query'\n *\n * function Post({ postId }: { postId: number }) {\n * const queryClient = useQueryClient()\n *\n * const { data, isError, error } = useQuery({\n * queryKey: ['post', postId],\n * queryFn: () => fetchPost(postId),\n * initialData: () =>\n * queryClient\n * .getQueryData<Array<Post>>(['posts'])\n * ?.find((post) => post.id === postId),\n * initialDataUpdatedAt: () =>\n * queryClient.getQueryState(['posts'])?.dataUpdatedAt,\n * })\n *\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return <h1>{data?.title}</h1>\n * }\n * ```\n * @example\n * Paginated data, keeping the previous page's data visible while the next page loads:\n * ```tsx\n * import { keepPreviousData, useQuery } from '@tanstack/react-query'\n * import { useState } from 'react'\n *\n * function Posts() {\n * const [page, setPage] = useState(0)\n *\n * const { data, isPlaceholderData, isError, error } = useQuery({\n * queryKey: ['posts', page],\n * queryFn: () => fetchPosts(page),\n * placeholderData: keepPreviousData,\n * })\n *\n * if (isError) return <span>Error: {error.message}</span>\n *\n * return (\n * <div>\n * <ul>\n * {data?.map((post) => <li key={post.id}>{post.title}</li>)}\n * </ul>\n * <button\n * disabled={isPlaceholderData}\n * onClick={() => setPage((old) => old + 1)}\n * >\n * Next Page\n * </button>\n * </div>\n * )\n * }\n * ```\n */\nexport function useQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n queryClient?: QueryClient,\n): UseQueryResult<TData, TError>\n\nexport function useQuery(options: UseQueryOptions, queryClient?: QueryClient) {\n return useBaseQuery(options, QueryObserver, queryClient)\n}\n"],"mappings":";;;;AAkSA,SAAgB,SAAS,SAA0B,aAA2B;CAC5E,OAAO,aAAa,SAAS,eAAe,WAAW;AACzD"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const require_suspense = require("./suspense.cjs");
|
|
4
4
|
const require_useBaseQuery = require("./useBaseQuery.cjs");
|
|
5
5
|
let _tanstack_query_core = require("@tanstack/query-core");
|
|
6
|
-
|
|
6
|
+
// src/useSuspenseInfiniteQuery.ts
|
|
7
7
|
/**
|
|
8
8
|
* The options for `useSuspenseInfiniteQuery` are the same as for `useInfiniteQuery`, except for `throwOnError`,
|
|
9
9
|
* `enabled`, and `placeholderData`.
|
|
@@ -100,7 +100,6 @@ function useSuspenseInfiniteQuery(options, queryClient) {
|
|
|
100
100
|
placeholderData: void 0
|
|
101
101
|
}, _tanstack_query_core.InfiniteQueryObserver, queryClient);
|
|
102
102
|
}
|
|
103
|
-
//#endregion
|
|
104
103
|
exports.useSuspenseInfiniteQuery = useSuspenseInfiniteQuery;
|
|
105
104
|
|
|
106
105
|
//# sourceMappingURL=useSuspenseInfiniteQuery.cjs.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { UseSuspenseInfiniteQueryOptions, UseSuspenseInfiniteQueryResult } from "./types.cjs";
|
|
2
2
|
import { DefaultError, InfiniteData, QueryClient, QueryKey } from "@tanstack/query-core";
|
|
3
|
-
//#region src/useSuspenseInfiniteQuery.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* The options for `useSuspenseInfiniteQuery` are the same as for `useInfiniteQuery`, except for `throwOnError`,
|
|
6
5
|
* `enabled`, and `placeholderData`.
|
|
@@ -86,5 +85,4 @@ import { DefaultError, InfiniteData, QueryClient, QueryKey } from "@tanstack/que
|
|
|
86
85
|
* ```
|
|
87
86
|
*/
|
|
88
87
|
export declare function useSuspenseInfiniteQuery<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, queryClient?: QueryClient): UseSuspenseInfiniteQueryResult<TData, TError>;
|
|
89
|
-
//#endregion
|
|
90
88
|
//# sourceMappingURL=useSuspenseInfiniteQuery.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSuspenseInfiniteQuery.d.cts","names":[],"sources":["../../src/useSuspenseInfiniteQuery.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSuspenseInfiniteQuery.d.cts","names":[],"sources":["../../src/useSuspenseInfiniteQuery.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAqGgB,yBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,gCACP,cACA,QACA,OACA,WACA,aAEF,cAAc,cACb,+BAA+B,OAAO"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { UseSuspenseInfiniteQueryOptions, UseSuspenseInfiniteQueryResult } from "./types.js";
|
|
2
2
|
import { DefaultError, InfiniteData, QueryClient, QueryKey } from "@tanstack/query-core";
|
|
3
|
-
//#region src/useSuspenseInfiniteQuery.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* The options for `useSuspenseInfiniteQuery` are the same as for `useInfiniteQuery`, except for `throwOnError`,
|
|
6
5
|
* `enabled`, and `placeholderData`.
|
|
@@ -86,5 +85,4 @@ import { DefaultError, InfiniteData, QueryClient, QueryKey } from "@tanstack/que
|
|
|
86
85
|
* ```
|
|
87
86
|
*/
|
|
88
87
|
export declare function useSuspenseInfiniteQuery<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, queryClient?: QueryClient): UseSuspenseInfiniteQueryResult<TData, TError>;
|
|
89
|
-
//#endregion
|
|
90
88
|
//# sourceMappingURL=useSuspenseInfiniteQuery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSuspenseInfiniteQuery.d.ts","names":[],"sources":["../../src/useSuspenseInfiniteQuery.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSuspenseInfiniteQuery.d.ts","names":[],"sources":["../../src/useSuspenseInfiniteQuery.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAqGgB,yBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,gCACP,cACA,QACA,OACA,WACA,aAEF,cAAc,cACb,+BAA+B,OAAO"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { defaultThrowOnError } from "./suspense.js";
|
|
3
3
|
import { useBaseQuery } from "./useBaseQuery.js";
|
|
4
4
|
import { InfiniteQueryObserver, skipToken } from "@tanstack/query-core";
|
|
5
|
-
|
|
5
|
+
// src/useSuspenseInfiniteQuery.ts
|
|
6
6
|
/**
|
|
7
7
|
* The options for `useSuspenseInfiniteQuery` are the same as for `useInfiniteQuery`, except for `throwOnError`,
|
|
8
8
|
* `enabled`, and `placeholderData`.
|
|
@@ -99,7 +99,6 @@ function useSuspenseInfiniteQuery(options, queryClient) {
|
|
|
99
99
|
placeholderData: void 0
|
|
100
100
|
}, InfiniteQueryObserver, queryClient);
|
|
101
101
|
}
|
|
102
|
-
//#endregion
|
|
103
102
|
export { useSuspenseInfiniteQuery };
|
|
104
103
|
|
|
105
104
|
//# sourceMappingURL=useSuspenseInfiniteQuery.js.map
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const require_suspense = require("./suspense.cjs");
|
|
4
4
|
const require_useQueries = require("./useQueries.cjs");
|
|
5
5
|
let _tanstack_query_core = require("@tanstack/query-core");
|
|
6
|
-
|
|
6
|
+
// src/useSuspenseQueries.ts
|
|
7
7
|
function useSuspenseQueries(options, queryClient) {
|
|
8
8
|
return require_useQueries.useQueries({
|
|
9
9
|
...options,
|
|
@@ -21,7 +21,6 @@ function useSuspenseQueries(options, queryClient) {
|
|
|
21
21
|
})
|
|
22
22
|
}, queryClient);
|
|
23
23
|
}
|
|
24
|
-
//#endregion
|
|
25
24
|
exports.useSuspenseQueries = useSuspenseQueries;
|
|
26
25
|
|
|
27
26
|
//# sourceMappingURL=useSuspenseQueries.cjs.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { UseSuspenseQueryOptions, UseSuspenseQueryResult } from "./types.cjs";
|
|
2
2
|
import { DefaultError, QueryClient, QueryFunction, ThrowOnError } from "@tanstack/query-core";
|
|
3
|
-
//#region src/useSuspenseQueries.d.ts
|
|
4
3
|
type MAXIMUM_DEPTH = 20;
|
|
5
4
|
type SkipTokenForUseQueries = symbol;
|
|
6
5
|
type GetUseSuspenseQueryOptions<T> = T extends {
|
|
@@ -368,5 +367,4 @@ export declare function useSuspenseQueries<T extends Array<any>, TCombinedResult
|
|
|
368
367
|
*/
|
|
369
368
|
combine?: (result: SuspenseQueriesResults<T>) => TCombinedResult;
|
|
370
369
|
}, queryClient?: QueryClient): TCombinedResult;
|
|
371
|
-
//#endregion
|
|
372
370
|
//# sourceMappingURL=useSuspenseQueries.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSuspenseQueries.d.cts","names":[],"sources":["../../src/useSuspenseQueries.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSuspenseQueries.d.cts","names":[],"sources":["../../src/useSuspenseQueries.ts"],"mappings":";;KAaK;KAGA;KAEA,2BAA2B,KAE9B;EACE,mBAAmB;EACnB,cAAc;EACd,YAAY;IAEV,wBAAwB,cAAc,QAAQ,SAC9C;EAAY,mBAAmB;EAAc,cAAc;IACzD,wBAAwB,cAAc,UACtC;EAAY,YAAY;EAAO,cAAc;IAC3C,iCAAiC,QAAQ,SAEzC,iBAAiB,oBAAoB,cAAc,SACjD,wBAAwB,cAAc,QAAQ,SAC9C,iBAAiB,oBAAoB,UACnC,wBAAwB,cAAc,UACtC,iBAAiB,gBACf,wBAAwB,gBAExB;EACI,UACI,oBAAoB,oBAAoB,aACxC;EACJ,UAAU,oBAAoB;EAC9B,eAAe,wBAAwB;IAEzC,wBACE,cACA,QACA,OACA,aAEF;EACI,UACI,oBAAoB,oBAAoB,aACxC;EACJ,eAAe,wBAAwB;IAEzC,wBACE,cACA,QACA,cACA,aAGF;KAEf,0BAA0B,KAE7B;EAAY;EAAkB,cAAc;EAAQ,YAAY;IAC5D,uBAAuB,OAAO,UAC9B;EAAY,mBAAmB;EAAc,cAAc;IACzD,uBAAuB,cAAc,UACrC;EAAY,YAAY;EAAO,cAAc;IAC3C,uBAAuB,OAAO,UAE9B,sBAAsB,cAAc,SAClC,uBAAuB,OAAO,UAC9B,iBAAiB,oBAAoB,UACnC,uBAAuB,cAAc,UACrC,iBAAiB,gBACf,uBAAuB,gBAEvB;EACI,UACI,oBAAoB,qBACpB;EACJ,UAAU,oBAAoB;EAC9B,eAAe,wBAAwB;IAEzC,uCACkB,QAAQ,eAAe,uBACvB,SAAS,eAAe,UAE1C;EACI,UACI,oBAAoB,qBACpB;EACJ,eAAe,wBAAwB;IAEzC,uBACE,8BACgB,SAAS,eAAe,UAG1C;;;;;;;;;;;;;;;;YAiBR,uBACV,UAAU,YACV,iBAAiB,iBACjB,eAAe,8BACb,yBAAyB,gBACzB,MAAM,2BACN,oBAEE,iBAAiB,YACX,UAAU,2BAA2B,SACzC,iBAAiB,eAAe,SAC9B,2BACM,YACA,UAAU,2BAA2B,YACrC,cAEN,uBAAuB,IACrB,IAGA,UAAU,MACN,8BACQ,oBACA,cACA,aACA,cAGV,MACE,wBAAwB,cAAc,QAAQ,OAAO,cAGvD,MAAM;;;;;;;;;;;;YAaR,uBACV,UAAU,YACV,iBAAiB,iBACjB,eAAe,8BACb,yBAAyB,gBACzB,MAAM,0BACN,oBAEE,iBAAiB,YACX,UAAU,0BAA0B,SACxC,iBAAiB,eAAe,SAC9B,2BACM,YACA,UAAU,0BAA0B,YACpC,iBAEH,WAAW,IAAI,0BAA0B,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAoKxC,mBACd,UAAU,YACV,kBAAkB,uBAAuB,IAEzC;;;;EAIE,sBACiB,uBAAuB,sBACpB,WAAW,IAAI,2BAA2B,EAAE;;;;;EAKhE,WAAW,QAAQ,uBAAuB,OAAO;GAEnD,cAAc,cACb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAuHa,mBACd,UAAU,YACV,kBAAkB,uBAAuB,IAEzC;;;;EAIE,sBAAsB,uBAAuB;;;;;EAK7C,WAAW,QAAQ,uBAAuB,OAAO;GAEnD,cAAc,cACb"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { UseSuspenseQueryOptions, UseSuspenseQueryResult } from "./types.js";
|
|
2
2
|
import { DefaultError, QueryClient, QueryFunction, ThrowOnError } from "@tanstack/query-core";
|
|
3
|
-
//#region src/useSuspenseQueries.d.ts
|
|
4
3
|
type MAXIMUM_DEPTH = 20;
|
|
5
4
|
type SkipTokenForUseQueries = symbol;
|
|
6
5
|
type GetUseSuspenseQueryOptions<T> = T extends {
|
|
@@ -368,5 +367,4 @@ export declare function useSuspenseQueries<T extends Array<any>, TCombinedResult
|
|
|
368
367
|
*/
|
|
369
368
|
combine?: (result: SuspenseQueriesResults<T>) => TCombinedResult;
|
|
370
369
|
}, queryClient?: QueryClient): TCombinedResult;
|
|
371
|
-
//#endregion
|
|
372
370
|
//# sourceMappingURL=useSuspenseQueries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSuspenseQueries.d.ts","names":[],"sources":["../../src/useSuspenseQueries.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSuspenseQueries.d.ts","names":[],"sources":["../../src/useSuspenseQueries.ts"],"mappings":";;KAaK;KAGA;KAEA,2BAA2B,KAE9B;EACE,mBAAmB;EACnB,cAAc;EACd,YAAY;IAEV,wBAAwB,cAAc,QAAQ,SAC9C;EAAY,mBAAmB;EAAc,cAAc;IACzD,wBAAwB,cAAc,UACtC;EAAY,YAAY;EAAO,cAAc;IAC3C,iCAAiC,QAAQ,SAEzC,iBAAiB,oBAAoB,cAAc,SACjD,wBAAwB,cAAc,QAAQ,SAC9C,iBAAiB,oBAAoB,UACnC,wBAAwB,cAAc,UACtC,iBAAiB,gBACf,wBAAwB,gBAExB;EACI,UACI,oBAAoB,oBAAoB,aACxC;EACJ,UAAU,oBAAoB;EAC9B,eAAe,wBAAwB;IAEzC,wBACE,cACA,QACA,OACA,aAEF;EACI,UACI,oBAAoB,oBAAoB,aACxC;EACJ,eAAe,wBAAwB;IAEzC,wBACE,cACA,QACA,cACA,aAGF;KAEf,0BAA0B,KAE7B;EAAY;EAAkB,cAAc;EAAQ,YAAY;IAC5D,uBAAuB,OAAO,UAC9B;EAAY,mBAAmB;EAAc,cAAc;IACzD,uBAAuB,cAAc,UACrC;EAAY,YAAY;EAAO,cAAc;IAC3C,uBAAuB,OAAO,UAE9B,sBAAsB,cAAc,SAClC,uBAAuB,OAAO,UAC9B,iBAAiB,oBAAoB,UACnC,uBAAuB,cAAc,UACrC,iBAAiB,gBACf,uBAAuB,gBAEvB;EACI,UACI,oBAAoB,qBACpB;EACJ,UAAU,oBAAoB;EAC9B,eAAe,wBAAwB;IAEzC,uCACkB,QAAQ,eAAe,uBACvB,SAAS,eAAe,UAE1C;EACI,UACI,oBAAoB,qBACpB;EACJ,eAAe,wBAAwB;IAEzC,uBACE,8BACgB,SAAS,eAAe,UAG1C;;;;;;;;;;;;;;;;YAiBR,uBACV,UAAU,YACV,iBAAiB,iBACjB,eAAe,8BACb,yBAAyB,gBACzB,MAAM,2BACN,oBAEE,iBAAiB,YACX,UAAU,2BAA2B,SACzC,iBAAiB,eAAe,SAC9B,2BACM,YACA,UAAU,2BAA2B,YACrC,cAEN,uBAAuB,IACrB,IAGA,UAAU,MACN,8BACQ,oBACA,cACA,aACA,cAGV,MACE,wBAAwB,cAAc,QAAQ,OAAO,cAGvD,MAAM;;;;;;;;;;;;YAaR,uBACV,UAAU,YACV,iBAAiB,iBACjB,eAAe,8BACb,yBAAyB,gBACzB,MAAM,0BACN,oBAEE,iBAAiB,YACX,UAAU,0BAA0B,SACxC,iBAAiB,eAAe,SAC9B,2BACM,YACA,UAAU,0BAA0B,YACpC,iBAEH,WAAW,IAAI,0BAA0B,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAoKxC,mBACd,UAAU,YACV,kBAAkB,uBAAuB,IAEzC;;;;EAIE,sBACiB,uBAAuB,sBACpB,WAAW,IAAI,2BAA2B,EAAE;;;;;EAKhE,WAAW,QAAQ,uBAAuB,OAAO;GAEnD,cAAc,cACb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAuHa,mBACd,UAAU,YACV,kBAAkB,uBAAuB,IAEzC;;;;EAIE,sBAAsB,uBAAuB;;;;;EAK7C,WAAW,QAAQ,uBAAuB,OAAO;GAEnD,cAAc,cACb"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { defaultThrowOnError } from "./suspense.js";
|
|
3
3
|
import { useQueries } from "./useQueries.js";
|
|
4
4
|
import { skipToken } from "@tanstack/query-core";
|
|
5
|
-
|
|
5
|
+
// src/useSuspenseQueries.ts
|
|
6
6
|
function useSuspenseQueries(options, queryClient) {
|
|
7
7
|
return useQueries({
|
|
8
8
|
...options,
|
|
@@ -20,7 +20,6 @@ function useSuspenseQueries(options, queryClient) {
|
|
|
20
20
|
})
|
|
21
21
|
}, queryClient);
|
|
22
22
|
}
|
|
23
|
-
//#endregion
|
|
24
23
|
export { useSuspenseQueries };
|
|
25
24
|
|
|
26
25
|
//# sourceMappingURL=useSuspenseQueries.js.map
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const require_suspense = require("./suspense.cjs");
|
|
4
4
|
const require_useBaseQuery = require("./useBaseQuery.cjs");
|
|
5
5
|
let _tanstack_query_core = require("@tanstack/query-core");
|
|
6
|
-
|
|
6
|
+
// src/useSuspenseQuery.ts
|
|
7
7
|
/**
|
|
8
8
|
* The options for `useSuspenseQuery` are the same as for `useQuery`, except for `throwOnError`, `enabled`, and
|
|
9
9
|
* `placeholderData` — and `queryFn` may not be `skipToken`, since Suspense hooks can't render a "disabled" state.
|
|
@@ -81,7 +81,6 @@ function useSuspenseQuery(options, queryClient) {
|
|
|
81
81
|
placeholderData: void 0
|
|
82
82
|
}, _tanstack_query_core.QueryObserver, queryClient);
|
|
83
83
|
}
|
|
84
|
-
//#endregion
|
|
85
84
|
exports.useSuspenseQuery = useSuspenseQuery;
|
|
86
85
|
|
|
87
86
|
//# sourceMappingURL=useSuspenseQuery.cjs.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { UseSuspenseQueryOptions, UseSuspenseQueryResult } from "./types.cjs";
|
|
2
2
|
import { DefaultError, QueryClient, QueryKey } from "@tanstack/query-core";
|
|
3
|
-
//#region src/useSuspenseQuery.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* The options for `useSuspenseQuery` are the same as for `useQuery`, except for `throwOnError`, `enabled`, and
|
|
6
5
|
* `placeholderData` — and `queryFn` may not be `skipToken`, since Suspense hooks can't render a "disabled" state.
|
|
@@ -67,5 +66,4 @@ import { DefaultError, QueryClient, QueryKey } from "@tanstack/query-core";
|
|
|
67
66
|
* ```
|
|
68
67
|
*/
|
|
69
68
|
export declare function useSuspenseQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UseSuspenseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): UseSuspenseQueryResult<TData, TError>;
|
|
70
|
-
//#endregion
|
|
71
69
|
//# sourceMappingURL=useSuspenseQuery.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSuspenseQuery.d.cts","names":[],"sources":["../../src/useSuspenseQuery.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSuspenseQuery.d.cts","names":[],"sources":["../../src/useSuspenseQuery.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAwEgB,iBACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,wBAAwB,cAAc,QAAQ,OAAO,YAC9D,cAAc,cACb,uBAAuB,OAAO"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { UseSuspenseQueryOptions, UseSuspenseQueryResult } from "./types.js";
|
|
2
2
|
import { DefaultError, QueryClient, QueryKey } from "@tanstack/query-core";
|
|
3
|
-
//#region src/useSuspenseQuery.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* The options for `useSuspenseQuery` are the same as for `useQuery`, except for `throwOnError`, `enabled`, and
|
|
6
5
|
* `placeholderData` — and `queryFn` may not be `skipToken`, since Suspense hooks can't render a "disabled" state.
|
|
@@ -67,5 +66,4 @@ import { DefaultError, QueryClient, QueryKey } from "@tanstack/query-core";
|
|
|
67
66
|
* ```
|
|
68
67
|
*/
|
|
69
68
|
export declare function useSuspenseQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UseSuspenseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): UseSuspenseQueryResult<TData, TError>;
|
|
70
|
-
//#endregion
|
|
71
69
|
//# sourceMappingURL=useSuspenseQuery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSuspenseQuery.d.ts","names":[],"sources":["../../src/useSuspenseQuery.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSuspenseQuery.d.ts","names":[],"sources":["../../src/useSuspenseQuery.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAwEgB,iBACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,wBAAwB,cAAc,QAAQ,OAAO,YAC9D,cAAc,cACb,uBAAuB,OAAO"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { defaultThrowOnError } from "./suspense.js";
|
|
3
3
|
import { useBaseQuery } from "./useBaseQuery.js";
|
|
4
4
|
import { QueryObserver, skipToken } from "@tanstack/query-core";
|
|
5
|
-
|
|
5
|
+
// src/useSuspenseQuery.ts
|
|
6
6
|
/**
|
|
7
7
|
* The options for `useSuspenseQuery` are the same as for `useQuery`, except for `throwOnError`, `enabled`, and
|
|
8
8
|
* `placeholderData` — and `queryFn` may not be `skipToken`, since Suspense hooks can't render a "disabled" state.
|
|
@@ -80,7 +80,6 @@ function useSuspenseQuery(options, queryClient) {
|
|
|
80
80
|
placeholderData: void 0
|
|
81
81
|
}, QueryObserver, queryClient);
|
|
82
82
|
}
|
|
83
|
-
//#endregion
|
|
84
83
|
export { useSuspenseQuery };
|
|
85
84
|
|
|
86
85
|
//# sourceMappingURL=useSuspenseQuery.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-query",
|
|
3
|
-
"version": "5.105.
|
|
3
|
+
"version": "5.105.1",
|
|
4
4
|
"description": "Hooks for managing, caching and syncing asynchronous and remote data in React",
|
|
5
5
|
"author": "tannerlinsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,20 +44,20 @@
|
|
|
44
44
|
"!build/codemods/**/__tests__"
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@tanstack/query-core": "5.105.
|
|
47
|
+
"@tanstack/query-core": "5.105.1"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@eslint-react/eslint-plugin": "^5.
|
|
51
|
-
"@tanstack/query-persist-client-core": "5.105.
|
|
50
|
+
"@eslint-react/eslint-plugin": "^5.28.8",
|
|
51
|
+
"@tanstack/query-persist-client-core": "5.105.1",
|
|
52
52
|
"@tanstack/query-test-utils": "0.0.0",
|
|
53
53
|
"@testing-library/react": "^16.1.0",
|
|
54
54
|
"@testing-library/react-render-stream": "^2.0.2",
|
|
55
|
-
"@types/react": "^19.
|
|
56
|
-
"@types/react-dom": "^19.
|
|
55
|
+
"@types/react": "^19.3.0",
|
|
56
|
+
"@types/react-dom": "^19.3.0",
|
|
57
57
|
"@vitejs/plugin-react": "^6.1.1",
|
|
58
58
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
59
|
-
"react": "^19.
|
|
60
|
-
"react-dom": "^19.
|
|
59
|
+
"react": "^19.3.1",
|
|
60
|
+
"react-dom": "^19.3.1",
|
|
61
61
|
"react-error-boundary": "^4.1.2",
|
|
62
62
|
"typescript": "6.0.3"
|
|
63
63
|
},
|
|
@@ -11,8 +11,9 @@ import type {
|
|
|
11
11
|
import type { UseInfiniteQueryOptions } from './types'
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* The options accepted by the `infiniteQueryOptions` overload selected when
|
|
15
|
-
* may be `undefined` while the query is
|
|
14
|
+
* The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is omitted, may be
|
|
15
|
+
* `undefined`, or is a function that may return `undefined` — `data` may be `undefined` while the query is
|
|
16
|
+
* `pending`.
|
|
16
17
|
* @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
|
|
17
18
|
* @template TError - The type of errors your `queryFn` may throw.
|
|
18
19
|
* @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,
|
|
@@ -49,9 +50,9 @@ export type UndefinedInitialDataInfiniteOptions<
|
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
/**
|
|
52
|
-
* The options accepted by the `infiniteQueryOptions` overload selected when
|
|
53
|
-
* `
|
|
54
|
-
* `skipToken`.
|
|
53
|
+
* The options accepted by the `infiniteQueryOptions` overload selected when `queryFn` is not `skipToken` and
|
|
54
|
+
* `initialData` is omitted, may be `undefined`, or is a function that may return `undefined` — same as
|
|
55
|
+
* {@link UndefinedInitialDataInfiniteOptions}, but `queryFn` may not be `skipToken`.
|
|
55
56
|
* @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
|
|
56
57
|
* @template TError - The type of errors your `queryFn` may throw.
|
|
57
58
|
* @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,
|
|
@@ -70,10 +71,11 @@ export type UnusedSkipTokenInfiniteOptions<
|
|
|
70
71
|
'queryFn'
|
|
71
72
|
> & {
|
|
72
73
|
/**
|
|
73
|
-
* `skipToken` is not allowed as a value here — this overload is selected when
|
|
74
|
-
* you don't intend to run the query yet,
|
|
75
|
-
*
|
|
76
|
-
*
|
|
74
|
+
* `skipToken` is not allowed as a value here — this overload is selected when `initialData` is omitted, may
|
|
75
|
+
* be `undefined`, or is a function that may return `undefined`. If you don't intend to run the query yet,
|
|
76
|
+
* set `enabled: false` — omitting `queryFn` alone still triggers a fetch that fails with "Missing queryFn"
|
|
77
|
+
* unless `enabled` is `false` or a default query function has been defined. A default query function only
|
|
78
|
+
* supplies `queryFn`; it doesn't defer the fetch on its own.
|
|
77
79
|
*/
|
|
78
80
|
queryFn?: Exclude<
|
|
79
81
|
UseInfiniteQueryOptions<
|
|
@@ -88,8 +90,8 @@ export type UnusedSkipTokenInfiniteOptions<
|
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
/**
|
|
91
|
-
* The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is
|
|
92
|
-
* never `undefined` (unless a `select` changes `TData` to include `undefined`).
|
|
93
|
+
* The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is known to be
|
|
94
|
+
* defined — `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`).
|
|
93
95
|
* @template TQueryFnData - The type of a single page, as your `queryFn` resolves it.
|
|
94
96
|
* @template TError - The type of errors your `queryFn` may throw.
|
|
95
97
|
* @template TData - The type `data` ends up as after `select` runs — defaults to `InfiniteData<TQueryFnData>`,
|
|
@@ -120,7 +122,6 @@ export type DefinedInitialDataInfiniteOptions<
|
|
|
120
122
|
initialData:
|
|
121
123
|
| NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>
|
|
122
124
|
| (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)
|
|
123
|
-
| undefined
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
/**
|
|
@@ -128,8 +129,8 @@ export type DefinedInitialDataInfiniteOptions<
|
|
|
128
129
|
* These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`.
|
|
129
130
|
* `options.queryKey` is required and is the query key to generate options for.
|
|
130
131
|
*
|
|
131
|
-
* This overload is selected when `initialData` is
|
|
132
|
-
* @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData`
|
|
132
|
+
* This overload is selected when `initialData` is known to be defined.
|
|
133
|
+
* @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData` known to be defined.
|
|
133
134
|
* @returns The same options object, typed so that `queryKey` carries the inferred data type.
|
|
134
135
|
* @remarks See {@link useInfiniteQuery} for examples that fetch further pages, from a button click or
|
|
135
136
|
* automatically as the user scrolls.
|
package/src/queryOptions.ts
CHANGED
|
@@ -11,8 +11,9 @@ import type {
|
|
|
11
11
|
import type { UseQueryOptions } from './types'
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* The options accepted by the `queryOptions` overload selected when
|
|
15
|
-
* `undefined` while the query is
|
|
14
|
+
* The options accepted by the `queryOptions` overload selected when `initialData` is omitted, may be
|
|
15
|
+
* `undefined`, or is a function that may return `undefined` — `data` may be `undefined` while the query is
|
|
16
|
+
* `pending`.
|
|
16
17
|
* @template TQueryFnData - The type your `queryFn` resolves to.
|
|
17
18
|
* @template TError - The type of errors your `queryFn` may throw.
|
|
18
19
|
* @template TData - The type `data` ends up as after `select` runs.
|
|
@@ -38,8 +39,9 @@ export type UndefinedInitialDataOptions<
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
/**
|
|
41
|
-
* The options accepted by the `queryOptions` overload selected when
|
|
42
|
-
*
|
|
42
|
+
* The options accepted by the `queryOptions` overload selected when `queryFn` is not `skipToken` and
|
|
43
|
+
* `initialData` is omitted, may be `undefined`, or is a function that may return `undefined` — same as
|
|
44
|
+
* {@link UndefinedInitialDataOptions}, but `queryFn` may not be `skipToken`.
|
|
43
45
|
* @template TQueryFnData - The type your `queryFn` resolves to.
|
|
44
46
|
* @template TError - The type of errors your `queryFn` may throw.
|
|
45
47
|
* @template TData - The type `data` ends up as after `select` runs.
|
|
@@ -55,10 +57,11 @@ export type UnusedSkipTokenOptions<
|
|
|
55
57
|
'queryFn'
|
|
56
58
|
> & {
|
|
57
59
|
/**
|
|
58
|
-
* `skipToken` is not allowed as a value here — this overload is selected when
|
|
59
|
-
* you don't intend to run the query yet,
|
|
60
|
-
*
|
|
61
|
-
*
|
|
60
|
+
* `skipToken` is not allowed as a value here — this overload is selected when `initialData` is omitted, may
|
|
61
|
+
* be `undefined`, or is a function that may return `undefined`. If you don't intend to run the query yet,
|
|
62
|
+
* set `enabled: false` — omitting `queryFn` alone still triggers a fetch that fails with "Missing queryFn"
|
|
63
|
+
* unless `enabled` is `false` or a default query function has been defined. A default query function only
|
|
64
|
+
* supplies `queryFn`; it doesn't defer the fetch on its own.
|
|
62
65
|
*/
|
|
63
66
|
queryFn?: Exclude<
|
|
64
67
|
UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>['queryFn'],
|
|
@@ -67,8 +70,8 @@ export type UnusedSkipTokenOptions<
|
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
/**
|
|
70
|
-
* The options accepted by the `queryOptions` overload selected when `initialData` is
|
|
71
|
-
* `undefined` (unless a `select` changes `TData` to include `undefined`).
|
|
73
|
+
* The options accepted by the `queryOptions` overload selected when `initialData` is known to be defined —
|
|
74
|
+
* `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`).
|
|
72
75
|
* @template TQueryFnData - The type your `queryFn` resolves to.
|
|
73
76
|
* @template TError - The type of errors your `queryFn` may throw.
|
|
74
77
|
* @template TData - The type `data` ends up as after `select` runs.
|
|
@@ -103,9 +106,9 @@ export type DefinedInitialDataOptions<
|
|
|
103
106
|
* be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and
|
|
104
107
|
* is the query key to generate options for.
|
|
105
108
|
*
|
|
106
|
-
* This overload is selected when `initialData` is
|
|
107
|
-
* a `select` changes `TData` to include `undefined`).
|
|
108
|
-
* @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData`
|
|
109
|
+
* This overload is selected when `initialData` is known to be defined, so the resulting `data` is never
|
|
110
|
+
* `undefined` (unless a `select` changes `TData` to include `undefined`).
|
|
111
|
+
* @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` known to be defined.
|
|
109
112
|
* @returns The same options object, typed so that `queryKey` carries the inferred data type.
|
|
110
113
|
* @see {@link useQuery} to run a query with these options.
|
|
111
114
|
* @see [The Query Options API](https://tkdodo.eu/blog/the-query-options-api) for more on this pattern.
|
package/src/useInfiniteQuery.ts
CHANGED
|
@@ -22,8 +22,8 @@ import type {
|
|
|
22
22
|
* The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of
|
|
23
23
|
* `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.
|
|
24
24
|
*
|
|
25
|
-
* This overload is selected when `initialData` is
|
|
26
|
-
* @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData`
|
|
25
|
+
* This overload is selected when `initialData` is known to be defined.
|
|
26
|
+
* @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to `useInfiniteQuery`, with `initialData` known to be defined.
|
|
27
27
|
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
28
28
|
* be used.
|
|
29
29
|
* @returns The same properties as `useQuery`, with the addition of `fetchNextPage`, `fetchPreviousPage`,
|
package/src/useIsFetching.ts
CHANGED
|
@@ -39,7 +39,7 @@ import type { QueryClient, QueryFilters } from '@tanstack/query-core'
|
|
|
39
39
|
* ```
|
|
40
40
|
*/
|
|
41
41
|
export function useIsFetching(
|
|
42
|
-
filters?: QueryFilters,
|
|
42
|
+
filters?: Omit<QueryFilters, 'fetchStatus'>,
|
|
43
43
|
queryClient?: QueryClient,
|
|
44
44
|
): number {
|
|
45
45
|
const client = useQueryClient(queryClient)
|
package/src/useQuery.ts
CHANGED
|
@@ -13,9 +13,9 @@ import type {
|
|
|
13
13
|
} from './queryOptions'
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* This overload is selected when `initialData` is
|
|
17
|
-
* a `select` changes `TData` to include `undefined`).
|
|
18
|
-
* @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData`
|
|
16
|
+
* This overload is selected when `initialData` is known to be defined, so the resulting `data` is never
|
|
17
|
+
* `undefined` (unless a `select` changes `TData` to include `undefined`).
|
|
18
|
+
* @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` known to be defined.
|
|
19
19
|
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
20
20
|
* be used.
|
|
21
21
|
* @returns The current query result, typed so that `status` is `success` — or `error` if a fetch attempt
|
|
@@ -57,8 +57,8 @@ export function useQuery<
|
|
|
57
57
|
): DefinedUseQueryResult<TData, TError>
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
-
* This overload is selected when `initialData` is omitted
|
|
61
|
-
* can be `undefined`.
|
|
60
|
+
* This overload is selected when `initialData` is omitted, may be `undefined`, or is a function that may
|
|
61
|
+
* return `undefined`, so the resulting `data` can be `undefined`.
|
|
62
62
|
* @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `useQuery`.
|
|
63
63
|
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
64
64
|
* be used.
|