@tanstack/preact-query 5.102.3 → 5.102.5
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 +43 -0
- package/build/legacy/HydrationBoundary.cjs.map +1 -1
- package/build/legacy/HydrationBoundary.d.cts +61 -0
- package/build/legacy/HydrationBoundary.d.cts.map +1 -1
- package/build/legacy/HydrationBoundary.d.ts +61 -0
- package/build/legacy/HydrationBoundary.d.ts.map +1 -1
- package/build/legacy/HydrationBoundary.js +43 -0
- package/build/legacy/HydrationBoundary.js.map +1 -1
- package/build/legacy/IsRestoringProvider.cjs +11 -0
- package/build/legacy/IsRestoringProvider.cjs.map +1 -1
- package/build/legacy/IsRestoringProvider.d.cts +11 -0
- package/build/legacy/IsRestoringProvider.d.cts.map +1 -1
- package/build/legacy/IsRestoringProvider.d.ts +11 -0
- package/build/legacy/IsRestoringProvider.d.ts.map +1 -1
- package/build/legacy/IsRestoringProvider.js +11 -0
- package/build/legacy/IsRestoringProvider.js.map +1 -1
- package/build/legacy/QueryClientProvider.cjs +30 -0
- package/build/legacy/QueryClientProvider.cjs.map +1 -1
- package/build/legacy/QueryClientProvider.d.cts +41 -0
- package/build/legacy/QueryClientProvider.d.cts.map +1 -1
- package/build/legacy/QueryClientProvider.d.ts +41 -0
- package/build/legacy/QueryClientProvider.d.ts.map +1 -1
- package/build/legacy/QueryClientProvider.js +30 -0
- package/build/legacy/QueryClientProvider.js.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.cjs +77 -0
- package/build/legacy/QueryErrorResetBoundary.cjs.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.d.cts +108 -0
- package/build/legacy/QueryErrorResetBoundary.d.cts.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.d.ts +108 -0
- package/build/legacy/QueryErrorResetBoundary.d.ts.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.js +77 -0
- package/build/legacy/QueryErrorResetBoundary.js.map +1 -1
- package/build/legacy/infiniteQueryOptions.cjs.map +1 -1
- package/build/legacy/infiniteQueryOptions.d.cts +187 -0
- package/build/legacy/infiniteQueryOptions.d.cts.map +1 -1
- package/build/legacy/infiniteQueryOptions.d.ts +187 -0
- package/build/legacy/infiniteQueryOptions.d.ts.map +1 -1
- package/build/legacy/infiniteQueryOptions.js.map +1 -1
- package/build/legacy/mutationOptions.cjs.map +1 -1
- package/build/legacy/mutationOptions.d.cts +68 -0
- package/build/legacy/mutationOptions.d.cts.map +1 -1
- package/build/legacy/mutationOptions.d.ts +68 -0
- package/build/legacy/mutationOptions.d.ts.map +1 -1
- package/build/legacy/mutationOptions.js.map +1 -1
- package/build/legacy/queryOptions.cjs.map +1 -1
- package/build/legacy/queryOptions.d.cts +198 -0
- package/build/legacy/queryOptions.d.cts.map +1 -1
- package/build/legacy/queryOptions.d.ts +198 -0
- package/build/legacy/queryOptions.d.ts.map +1 -1
- package/build/legacy/queryOptions.js.map +1 -1
- package/build/legacy/types.cjs.map +1 -1
- package/build/legacy/types.d.cts +228 -2
- package/build/legacy/types.d.cts.map +1 -1
- package/build/legacy/types.d.ts +228 -2
- package/build/legacy/types.d.ts.map +1 -1
- package/build/legacy/types.js.map +1 -1
- package/build/legacy/useInfiniteQuery.cjs.map +1 -1
- package/build/legacy/useInfiniteQuery.d.cts +120 -0
- package/build/legacy/useInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/useInfiniteQuery.d.ts +120 -0
- package/build/legacy/useInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/useInfiniteQuery.js.map +1 -1
- package/build/legacy/useIsFetching.cjs +34 -0
- package/build/legacy/useIsFetching.cjs.map +1 -1
- package/build/legacy/useIsFetching.d.cts +34 -0
- package/build/legacy/useIsFetching.d.cts.map +1 -1
- package/build/legacy/useIsFetching.d.ts +34 -0
- package/build/legacy/useIsFetching.d.ts.map +1 -1
- package/build/legacy/useIsFetching.js +34 -0
- package/build/legacy/useIsFetching.js.map +1 -1
- package/build/legacy/useMutation.cjs +170 -0
- package/build/legacy/useMutation.cjs.map +1 -1
- package/build/legacy/useMutation.d.cts +170 -0
- package/build/legacy/useMutation.d.cts.map +1 -1
- package/build/legacy/useMutation.d.ts +170 -0
- package/build/legacy/useMutation.d.ts.map +1 -1
- package/build/legacy/useMutation.js +170 -0
- package/build/legacy/useMutation.js.map +1 -1
- package/build/legacy/useMutationState.cjs +74 -0
- package/build/legacy/useMutationState.cjs.map +1 -1
- package/build/legacy/useMutationState.d.cts +74 -0
- package/build/legacy/useMutationState.d.cts.map +1 -1
- package/build/legacy/useMutationState.d.ts +74 -0
- package/build/legacy/useMutationState.d.ts.map +1 -1
- package/build/legacy/useMutationState.js +74 -0
- package/build/legacy/useMutationState.js.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.cjs +44 -0
- package/build/legacy/usePrefetchInfiniteQuery.cjs.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.cts +44 -0
- package/build/legacy/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.ts +44 -0
- package/build/legacy/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.js +44 -0
- package/build/legacy/usePrefetchInfiniteQuery.js.map +1 -1
- package/build/legacy/usePrefetchQuery.cjs +35 -0
- package/build/legacy/usePrefetchQuery.cjs.map +1 -1
- package/build/legacy/usePrefetchQuery.d.cts +35 -0
- package/build/legacy/usePrefetchQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchQuery.d.ts +35 -0
- package/build/legacy/usePrefetchQuery.d.ts.map +1 -1
- package/build/legacy/usePrefetchQuery.js +35 -0
- package/build/legacy/usePrefetchQuery.js.map +1 -1
- package/build/legacy/useQueries.cjs +50 -0
- package/build/legacy/useQueries.cjs.map +1 -1
- package/build/legacy/useQueries.d.cts +85 -2
- package/build/legacy/useQueries.d.cts.map +1 -1
- package/build/legacy/useQueries.d.ts +85 -2
- package/build/legacy/useQueries.d.ts.map +1 -1
- package/build/legacy/useQueries.js +50 -0
- package/build/legacy/useQueries.js.map +1 -1
- package/build/legacy/useQuery.cjs.map +1 -1
- package/build/legacy/useQuery.d.cts +186 -0
- package/build/legacy/useQuery.d.cts.map +1 -1
- package/build/legacy/useQuery.d.ts +186 -0
- package/build/legacy/useQuery.d.ts.map +1 -1
- package/build/legacy/useQuery.js.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.cjs +56 -0
- package/build/legacy/useSuspenseInfiniteQuery.cjs.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.d.cts +56 -0
- package/build/legacy/useSuspenseInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.d.ts +56 -0
- package/build/legacy/useSuspenseInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.js +56 -0
- package/build/legacy/useSuspenseInfiniteQuery.js.map +1 -1
- package/build/legacy/useSuspenseQueries.cjs.map +1 -1
- package/build/legacy/useSuspenseQueries.d.cts +196 -2
- package/build/legacy/useSuspenseQueries.d.cts.map +1 -1
- package/build/legacy/useSuspenseQueries.d.ts +196 -2
- package/build/legacy/useSuspenseQueries.d.ts.map +1 -1
- package/build/legacy/useSuspenseQueries.js.map +1 -1
- package/build/legacy/useSuspenseQuery.cjs +47 -0
- package/build/legacy/useSuspenseQuery.cjs.map +1 -1
- package/build/legacy/useSuspenseQuery.d.cts +47 -0
- package/build/legacy/useSuspenseQuery.d.cts.map +1 -1
- package/build/legacy/useSuspenseQuery.d.ts +47 -0
- package/build/legacy/useSuspenseQuery.d.ts.map +1 -1
- package/build/legacy/useSuspenseQuery.js +47 -0
- package/build/legacy/useSuspenseQuery.js.map +1 -1
- package/build/modern/HydrationBoundary.cjs +43 -0
- package/build/modern/HydrationBoundary.cjs.map +1 -1
- package/build/modern/HydrationBoundary.d.cts +61 -0
- package/build/modern/HydrationBoundary.d.cts.map +1 -1
- package/build/modern/HydrationBoundary.d.ts +61 -0
- package/build/modern/HydrationBoundary.d.ts.map +1 -1
- package/build/modern/HydrationBoundary.js +43 -0
- package/build/modern/HydrationBoundary.js.map +1 -1
- package/build/modern/IsRestoringProvider.cjs +11 -0
- package/build/modern/IsRestoringProvider.cjs.map +1 -1
- package/build/modern/IsRestoringProvider.d.cts +11 -0
- package/build/modern/IsRestoringProvider.d.cts.map +1 -1
- package/build/modern/IsRestoringProvider.d.ts +11 -0
- package/build/modern/IsRestoringProvider.d.ts.map +1 -1
- package/build/modern/IsRestoringProvider.js +11 -0
- package/build/modern/IsRestoringProvider.js.map +1 -1
- package/build/modern/QueryClientProvider.cjs +30 -0
- package/build/modern/QueryClientProvider.cjs.map +1 -1
- package/build/modern/QueryClientProvider.d.cts +41 -0
- package/build/modern/QueryClientProvider.d.cts.map +1 -1
- package/build/modern/QueryClientProvider.d.ts +41 -0
- package/build/modern/QueryClientProvider.d.ts.map +1 -1
- package/build/modern/QueryClientProvider.js +30 -0
- package/build/modern/QueryClientProvider.js.map +1 -1
- package/build/modern/QueryErrorResetBoundary.cjs +77 -0
- package/build/modern/QueryErrorResetBoundary.cjs.map +1 -1
- package/build/modern/QueryErrorResetBoundary.d.cts +108 -0
- package/build/modern/QueryErrorResetBoundary.d.cts.map +1 -1
- package/build/modern/QueryErrorResetBoundary.d.ts +108 -0
- package/build/modern/QueryErrorResetBoundary.d.ts.map +1 -1
- package/build/modern/QueryErrorResetBoundary.js +77 -0
- package/build/modern/QueryErrorResetBoundary.js.map +1 -1
- package/build/modern/infiniteQueryOptions.cjs.map +1 -1
- package/build/modern/infiniteQueryOptions.d.cts +187 -0
- package/build/modern/infiniteQueryOptions.d.cts.map +1 -1
- package/build/modern/infiniteQueryOptions.d.ts +187 -0
- package/build/modern/infiniteQueryOptions.d.ts.map +1 -1
- package/build/modern/infiniteQueryOptions.js.map +1 -1
- package/build/modern/mutationOptions.cjs.map +1 -1
- package/build/modern/mutationOptions.d.cts +68 -0
- package/build/modern/mutationOptions.d.cts.map +1 -1
- package/build/modern/mutationOptions.d.ts +68 -0
- package/build/modern/mutationOptions.d.ts.map +1 -1
- package/build/modern/mutationOptions.js.map +1 -1
- package/build/modern/queryOptions.cjs.map +1 -1
- package/build/modern/queryOptions.d.cts +198 -0
- package/build/modern/queryOptions.d.cts.map +1 -1
- package/build/modern/queryOptions.d.ts +198 -0
- package/build/modern/queryOptions.d.ts.map +1 -1
- package/build/modern/queryOptions.js.map +1 -1
- package/build/modern/types.cjs.map +1 -1
- package/build/modern/types.d.cts +228 -2
- package/build/modern/types.d.cts.map +1 -1
- package/build/modern/types.d.ts +228 -2
- package/build/modern/types.d.ts.map +1 -1
- package/build/modern/types.js.map +1 -1
- package/build/modern/useInfiniteQuery.cjs.map +1 -1
- package/build/modern/useInfiniteQuery.d.cts +120 -0
- package/build/modern/useInfiniteQuery.d.cts.map +1 -1
- package/build/modern/useInfiniteQuery.d.ts +120 -0
- package/build/modern/useInfiniteQuery.d.ts.map +1 -1
- package/build/modern/useInfiniteQuery.js.map +1 -1
- package/build/modern/useIsFetching.cjs +34 -0
- package/build/modern/useIsFetching.cjs.map +1 -1
- package/build/modern/useIsFetching.d.cts +34 -0
- package/build/modern/useIsFetching.d.cts.map +1 -1
- package/build/modern/useIsFetching.d.ts +34 -0
- package/build/modern/useIsFetching.d.ts.map +1 -1
- package/build/modern/useIsFetching.js +34 -0
- package/build/modern/useIsFetching.js.map +1 -1
- package/build/modern/useMutation.cjs +170 -0
- package/build/modern/useMutation.cjs.map +1 -1
- package/build/modern/useMutation.d.cts +170 -0
- package/build/modern/useMutation.d.cts.map +1 -1
- package/build/modern/useMutation.d.ts +170 -0
- package/build/modern/useMutation.d.ts.map +1 -1
- package/build/modern/useMutation.js +170 -0
- package/build/modern/useMutation.js.map +1 -1
- package/build/modern/useMutationState.cjs +74 -0
- package/build/modern/useMutationState.cjs.map +1 -1
- package/build/modern/useMutationState.d.cts +74 -0
- package/build/modern/useMutationState.d.cts.map +1 -1
- package/build/modern/useMutationState.d.ts +74 -0
- package/build/modern/useMutationState.d.ts.map +1 -1
- package/build/modern/useMutationState.js +74 -0
- package/build/modern/useMutationState.js.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.cjs +44 -0
- package/build/modern/usePrefetchInfiniteQuery.cjs.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.cts +44 -0
- package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.ts +44 -0
- package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.js +44 -0
- package/build/modern/usePrefetchInfiniteQuery.js.map +1 -1
- package/build/modern/usePrefetchQuery.cjs +35 -0
- package/build/modern/usePrefetchQuery.cjs.map +1 -1
- package/build/modern/usePrefetchQuery.d.cts +35 -0
- package/build/modern/usePrefetchQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchQuery.d.ts +35 -0
- package/build/modern/usePrefetchQuery.d.ts.map +1 -1
- package/build/modern/usePrefetchQuery.js +35 -0
- package/build/modern/usePrefetchQuery.js.map +1 -1
- package/build/modern/useQueries.cjs +50 -0
- package/build/modern/useQueries.cjs.map +1 -1
- package/build/modern/useQueries.d.cts +85 -2
- package/build/modern/useQueries.d.cts.map +1 -1
- package/build/modern/useQueries.d.ts +85 -2
- package/build/modern/useQueries.d.ts.map +1 -1
- package/build/modern/useQueries.js +50 -0
- package/build/modern/useQueries.js.map +1 -1
- package/build/modern/useQuery.cjs.map +1 -1
- package/build/modern/useQuery.d.cts +186 -0
- package/build/modern/useQuery.d.cts.map +1 -1
- package/build/modern/useQuery.d.ts +186 -0
- package/build/modern/useQuery.d.ts.map +1 -1
- package/build/modern/useQuery.js.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.cjs +56 -0
- package/build/modern/useSuspenseInfiniteQuery.cjs.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.d.cts +56 -0
- package/build/modern/useSuspenseInfiniteQuery.d.cts.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.d.ts +56 -0
- package/build/modern/useSuspenseInfiniteQuery.d.ts.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.js +56 -0
- package/build/modern/useSuspenseInfiniteQuery.js.map +1 -1
- package/build/modern/useSuspenseQueries.cjs.map +1 -1
- package/build/modern/useSuspenseQueries.d.cts +196 -2
- package/build/modern/useSuspenseQueries.d.cts.map +1 -1
- package/build/modern/useSuspenseQueries.d.ts +196 -2
- package/build/modern/useSuspenseQueries.d.ts.map +1 -1
- package/build/modern/useSuspenseQueries.js.map +1 -1
- package/build/modern/useSuspenseQuery.cjs +47 -0
- package/build/modern/useSuspenseQuery.cjs.map +1 -1
- package/build/modern/useSuspenseQuery.d.cts +47 -0
- package/build/modern/useSuspenseQuery.d.cts.map +1 -1
- package/build/modern/useSuspenseQuery.d.ts +47 -0
- package/build/modern/useSuspenseQuery.d.ts.map +1 -1
- package/build/modern/useSuspenseQuery.js +47 -0
- package/build/modern/useSuspenseQuery.js.map +1 -1
- package/package.json +3 -3
- package/src/HydrationBoundary.tsx +61 -0
- package/src/IsRestoringProvider.ts +12 -0
- package/src/QueryClientProvider.tsx +41 -0
- package/src/QueryErrorResetBoundary.tsx +111 -0
- package/src/infiniteQueryOptions.ts +187 -0
- package/src/mutationOptions.ts +68 -0
- package/src/queryOptions.ts +198 -0
- package/src/types.ts +228 -2
- package/src/useInfiniteQuery.ts +120 -0
- package/src/useIsFetching.ts +34 -0
- package/src/useMutation.ts +170 -0
- package/src/useMutationState.ts +74 -0
- package/src/usePrefetchInfiniteQuery.tsx +44 -0
- package/src/usePrefetchQuery.tsx +35 -0
- package/src/useQueries.ts +85 -2
- package/src/useQuery.ts +186 -0
- package/src/useSuspenseInfiniteQuery.ts +56 -0
- package/src/useSuspenseQueries.ts +196 -2
- package/src/useSuspenseQuery.ts +47 -0
|
@@ -2,8 +2,194 @@ import { DefinedUseQueryResult, UseQueryOptions, UseQueryResult } from "./types.
|
|
|
2
2
|
import { DefinedInitialDataOptions, UndefinedInitialDataOptions } from "./queryOptions.cjs";
|
|
3
3
|
import { DefaultError, QueryClient, QueryKey } from "@tanstack/query-core";
|
|
4
4
|
//#region src/useQuery.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
|
|
9
|
+
* @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` set.
|
|
10
|
+
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
11
|
+
* be used.
|
|
12
|
+
* @returns The current query result, typed so that `status` is `success` — or `error` if a fetch attempt
|
|
13
|
+
* fails while keeping the existing data (`status` never resolves to `pending` in this overload's type,
|
|
14
|
+
* since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived booleans for convenience.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* import { useQuery } from '@tanstack/preact-query'
|
|
19
|
+
*
|
|
20
|
+
* function Posts() {
|
|
21
|
+
* // `data` is `Post[]`, never `undefined`, thanks to `initialData`.
|
|
22
|
+
* const { data } = useQuery({
|
|
23
|
+
* queryKey: ['posts'],
|
|
24
|
+
* queryFn: fetchPosts,
|
|
25
|
+
* initialData: [],
|
|
26
|
+
* })
|
|
27
|
+
*
|
|
28
|
+
* return <>{data.map((post) => <p key={post.id}>{post.title}</p>)}</>
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
5
32
|
declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): DefinedUseQueryResult<TData, TError>;
|
|
33
|
+
/**
|
|
34
|
+
* @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
|
|
35
|
+
* @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `useQuery`.
|
|
36
|
+
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
37
|
+
* be used.
|
|
38
|
+
* @returns The current query result. `status` is `pending` if there is no cached data and no query attempt
|
|
39
|
+
* has finished yet, `error` if the query attempt resulted in an error, or `success` if the query has data to
|
|
40
|
+
* display. `isPending`/`isSuccess`/`isError` are derived booleans for convenience.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* import { queryOptions, useQuery } from '@tanstack/preact-query'
|
|
45
|
+
*
|
|
46
|
+
* const postsOptions = queryOptions({
|
|
47
|
+
* queryKey: ['posts'],
|
|
48
|
+
* queryFn: fetchPosts,
|
|
49
|
+
* })
|
|
50
|
+
*
|
|
51
|
+
* function Posts() {
|
|
52
|
+
* const { status, data, error, isFetching } = useQuery(postsOptions)
|
|
53
|
+
*
|
|
54
|
+
* if (status === 'pending') return 'Loading...'
|
|
55
|
+
* if (status === 'error') return <span>Error: {error.message}</span>
|
|
56
|
+
*
|
|
57
|
+
* return (
|
|
58
|
+
* <div>
|
|
59
|
+
* {data.map((post) => (
|
|
60
|
+
* <p key={post.id}>{post.title}</p>
|
|
61
|
+
* ))}
|
|
62
|
+
* <div>{isFetching ? 'Background Updating...' : ' '}</div>
|
|
63
|
+
* </div>
|
|
64
|
+
* )
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* The same query, checking `isPending`/`isError` instead of `status` — pick whichever reads better to you:
|
|
70
|
+
* ```tsx
|
|
71
|
+
* import { useQuery } from '@tanstack/preact-query'
|
|
72
|
+
*
|
|
73
|
+
* function Posts() {
|
|
74
|
+
* const { isPending, isError, data, error } = useQuery({
|
|
75
|
+
* queryKey: ['posts'],
|
|
76
|
+
* queryFn: fetchPosts,
|
|
77
|
+
* })
|
|
78
|
+
*
|
|
79
|
+
* if (isPending) return 'Loading...'
|
|
80
|
+
* if (isError) return <span>Error: {error.message}</span>
|
|
81
|
+
*
|
|
82
|
+
* return <>{data.map((post) => <p key={post.id}>{post.title}</p>)}</>
|
|
83
|
+
* }
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
6
86
|
declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): UseQueryResult<TData, TError>;
|
|
87
|
+
/**
|
|
88
|
+
* @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
|
|
89
|
+
* @param options - The {@link UseQueryOptions} to use — everything you can pass to `useQuery`.
|
|
90
|
+
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
91
|
+
* be used.
|
|
92
|
+
* @returns The current query result. `status` is `pending` if there is no cached data and no query attempt
|
|
93
|
+
* has finished yet, `error` if the query attempt resulted in an error, or `success` if the query has data to
|
|
94
|
+
* display. `isPending`/`isSuccess`/`isError` are derived booleans for convenience.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```tsx
|
|
98
|
+
* import { queryOptions, useQuery } from '@tanstack/preact-query'
|
|
99
|
+
*
|
|
100
|
+
* const postsOptions = queryOptions({
|
|
101
|
+
* queryKey: ['posts'],
|
|
102
|
+
* queryFn: fetchPosts,
|
|
103
|
+
* })
|
|
104
|
+
*
|
|
105
|
+
* function Posts() {
|
|
106
|
+
* const { status, data, error, isFetching } = useQuery(postsOptions)
|
|
107
|
+
*
|
|
108
|
+
* if (status === 'pending') return 'Loading...'
|
|
109
|
+
* if (status === 'error') return <span>Error: {error.message}</span>
|
|
110
|
+
*
|
|
111
|
+
* return (
|
|
112
|
+
* <div>
|
|
113
|
+
* {data.map((post) => (
|
|
114
|
+
* <p key={post.id}>{post.title}</p>
|
|
115
|
+
* ))}
|
|
116
|
+
* <div>{isFetching ? 'Background Updating...' : ' '}</div>
|
|
117
|
+
* </div>
|
|
118
|
+
* )
|
|
119
|
+
* }
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* A dependent query, only enabled once `postId` is set — use `isLoading`, not `isPending`, so the
|
|
124
|
+
* loading state doesn't show while the query is disabled:
|
|
125
|
+
* ```tsx
|
|
126
|
+
* import { useQuery } from '@tanstack/preact-query'
|
|
127
|
+
*
|
|
128
|
+
* function Post({ postId }: { postId: number | undefined }) {
|
|
129
|
+
* const { data, isLoading, isError, error } = useQuery({
|
|
130
|
+
* queryKey: ['post', postId],
|
|
131
|
+
* queryFn: () => fetchPost(postId!),
|
|
132
|
+
* enabled: postId != null,
|
|
133
|
+
* })
|
|
134
|
+
*
|
|
135
|
+
* if (postId == null) return 'Select a post'
|
|
136
|
+
* if (isLoading) return 'Loading...'
|
|
137
|
+
* if (isError) return <span>Error: {error.message}</span>
|
|
138
|
+
*
|
|
139
|
+
* return <h1>{data?.title}</h1>
|
|
140
|
+
* }
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* Seeding a detail query from an already-cached list, to skip the loading state:
|
|
145
|
+
* ```tsx
|
|
146
|
+
* import { useQuery, useQueryClient } from '@tanstack/preact-query'
|
|
147
|
+
*
|
|
148
|
+
* function Post({ postId }: { postId: number }) {
|
|
149
|
+
* const queryClient = useQueryClient()
|
|
150
|
+
*
|
|
151
|
+
* const { data } = useQuery({
|
|
152
|
+
* queryKey: ['post', postId],
|
|
153
|
+
* queryFn: () => fetchPost(postId),
|
|
154
|
+
* initialData: () =>
|
|
155
|
+
* queryClient
|
|
156
|
+
* .getQueryData<Array<Post>>(['posts'])
|
|
157
|
+
* ?.find((post) => post.id === postId),
|
|
158
|
+
* })
|
|
159
|
+
*
|
|
160
|
+
* return <h1>{data?.title}</h1>
|
|
161
|
+
* }
|
|
162
|
+
* ```
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* Paginated data, keeping the previous page's data visible while the next page loads:
|
|
166
|
+
* ```tsx
|
|
167
|
+
* import { keepPreviousData, useQuery } from '@tanstack/preact-query'
|
|
168
|
+
* import { useState } from 'preact/hooks'
|
|
169
|
+
*
|
|
170
|
+
* function Posts() {
|
|
171
|
+
* const [page, setPage] = useState(0)
|
|
172
|
+
*
|
|
173
|
+
* const { data, isPlaceholderData } = useQuery({
|
|
174
|
+
* queryKey: ['posts', page],
|
|
175
|
+
* queryFn: () => fetchPosts(page),
|
|
176
|
+
* placeholderData: keepPreviousData,
|
|
177
|
+
* })
|
|
178
|
+
*
|
|
179
|
+
* return (
|
|
180
|
+
* <div>
|
|
181
|
+
* {data?.map((post) => <p key={post.id}>{post.title}</p>)}
|
|
182
|
+
* <button
|
|
183
|
+
* disabled={isPlaceholderData}
|
|
184
|
+
* onClick={() => setPage((old) => old + 1)}
|
|
185
|
+
* >
|
|
186
|
+
* Next Page
|
|
187
|
+
* </button>
|
|
188
|
+
* </div>
|
|
189
|
+
* )
|
|
190
|
+
* }
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
7
193
|
declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): UseQueryResult<TData, TError>;
|
|
8
194
|
//#endregion
|
|
9
195
|
export { useQuery };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuery.d.cts","names":[],"sources":["../../src/useQuery.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useQuery.d.cts","names":[],"sources":["../../src/useQuery.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyCgB,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,0BAA0B,cAAc,QAAQ,OAAO,YAChE,cAAc,cACb,sBAAsB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuDhB,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,4BAA4B,cAAc,QAAQ,OAAO,YAClE,cAAc,cACb,eAAe,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4GT,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,gBAAgB,cAAc,QAAQ,OAAO,YACtD,cAAc,cACb,eAAe,OAAO"}
|
|
@@ -2,8 +2,194 @@ import { DefinedUseQueryResult, UseQueryOptions, UseQueryResult } from "./types.
|
|
|
2
2
|
import { DefinedInitialDataOptions, UndefinedInitialDataOptions } from "./queryOptions.js";
|
|
3
3
|
import { DefaultError, QueryClient, QueryKey } from "@tanstack/query-core";
|
|
4
4
|
//#region src/useQuery.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
|
|
9
|
+
* @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `useQuery`, with `initialData` set.
|
|
10
|
+
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
11
|
+
* be used.
|
|
12
|
+
* @returns The current query result, typed so that `status` is `success` — or `error` if a fetch attempt
|
|
13
|
+
* fails while keeping the existing data (`status` never resolves to `pending` in this overload's type,
|
|
14
|
+
* since `initialData` guarantees data upfront). `isSuccess`/`isError` are derived booleans for convenience.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* import { useQuery } from '@tanstack/preact-query'
|
|
19
|
+
*
|
|
20
|
+
* function Posts() {
|
|
21
|
+
* // `data` is `Post[]`, never `undefined`, thanks to `initialData`.
|
|
22
|
+
* const { data } = useQuery({
|
|
23
|
+
* queryKey: ['posts'],
|
|
24
|
+
* queryFn: fetchPosts,
|
|
25
|
+
* initialData: [],
|
|
26
|
+
* })
|
|
27
|
+
*
|
|
28
|
+
* return <>{data.map((post) => <p key={post.id}>{post.title}</p>)}</>
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
5
32
|
declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): DefinedUseQueryResult<TData, TError>;
|
|
33
|
+
/**
|
|
34
|
+
* @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
|
|
35
|
+
* @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `useQuery`.
|
|
36
|
+
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
37
|
+
* be used.
|
|
38
|
+
* @returns The current query result. `status` is `pending` if there is no cached data and no query attempt
|
|
39
|
+
* has finished yet, `error` if the query attempt resulted in an error, or `success` if the query has data to
|
|
40
|
+
* display. `isPending`/`isSuccess`/`isError` are derived booleans for convenience.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* import { queryOptions, useQuery } from '@tanstack/preact-query'
|
|
45
|
+
*
|
|
46
|
+
* const postsOptions = queryOptions({
|
|
47
|
+
* queryKey: ['posts'],
|
|
48
|
+
* queryFn: fetchPosts,
|
|
49
|
+
* })
|
|
50
|
+
*
|
|
51
|
+
* function Posts() {
|
|
52
|
+
* const { status, data, error, isFetching } = useQuery(postsOptions)
|
|
53
|
+
*
|
|
54
|
+
* if (status === 'pending') return 'Loading...'
|
|
55
|
+
* if (status === 'error') return <span>Error: {error.message}</span>
|
|
56
|
+
*
|
|
57
|
+
* return (
|
|
58
|
+
* <div>
|
|
59
|
+
* {data.map((post) => (
|
|
60
|
+
* <p key={post.id}>{post.title}</p>
|
|
61
|
+
* ))}
|
|
62
|
+
* <div>{isFetching ? 'Background Updating...' : ' '}</div>
|
|
63
|
+
* </div>
|
|
64
|
+
* )
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* The same query, checking `isPending`/`isError` instead of `status` — pick whichever reads better to you:
|
|
70
|
+
* ```tsx
|
|
71
|
+
* import { useQuery } from '@tanstack/preact-query'
|
|
72
|
+
*
|
|
73
|
+
* function Posts() {
|
|
74
|
+
* const { isPending, isError, data, error } = useQuery({
|
|
75
|
+
* queryKey: ['posts'],
|
|
76
|
+
* queryFn: fetchPosts,
|
|
77
|
+
* })
|
|
78
|
+
*
|
|
79
|
+
* if (isPending) return 'Loading...'
|
|
80
|
+
* if (isError) return <span>Error: {error.message}</span>
|
|
81
|
+
*
|
|
82
|
+
* return <>{data.map((post) => <p key={post.id}>{post.title}</p>)}</>
|
|
83
|
+
* }
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
6
86
|
declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): UseQueryResult<TData, TError>;
|
|
87
|
+
/**
|
|
88
|
+
* @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.
|
|
89
|
+
* @param options - The {@link UseQueryOptions} to use — everything you can pass to `useQuery`.
|
|
90
|
+
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
91
|
+
* be used.
|
|
92
|
+
* @returns The current query result. `status` is `pending` if there is no cached data and no query attempt
|
|
93
|
+
* has finished yet, `error` if the query attempt resulted in an error, or `success` if the query has data to
|
|
94
|
+
* display. `isPending`/`isSuccess`/`isError` are derived booleans for convenience.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```tsx
|
|
98
|
+
* import { queryOptions, useQuery } from '@tanstack/preact-query'
|
|
99
|
+
*
|
|
100
|
+
* const postsOptions = queryOptions({
|
|
101
|
+
* queryKey: ['posts'],
|
|
102
|
+
* queryFn: fetchPosts,
|
|
103
|
+
* })
|
|
104
|
+
*
|
|
105
|
+
* function Posts() {
|
|
106
|
+
* const { status, data, error, isFetching } = useQuery(postsOptions)
|
|
107
|
+
*
|
|
108
|
+
* if (status === 'pending') return 'Loading...'
|
|
109
|
+
* if (status === 'error') return <span>Error: {error.message}</span>
|
|
110
|
+
*
|
|
111
|
+
* return (
|
|
112
|
+
* <div>
|
|
113
|
+
* {data.map((post) => (
|
|
114
|
+
* <p key={post.id}>{post.title}</p>
|
|
115
|
+
* ))}
|
|
116
|
+
* <div>{isFetching ? 'Background Updating...' : ' '}</div>
|
|
117
|
+
* </div>
|
|
118
|
+
* )
|
|
119
|
+
* }
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* A dependent query, only enabled once `postId` is set — use `isLoading`, not `isPending`, so the
|
|
124
|
+
* loading state doesn't show while the query is disabled:
|
|
125
|
+
* ```tsx
|
|
126
|
+
* import { useQuery } from '@tanstack/preact-query'
|
|
127
|
+
*
|
|
128
|
+
* function Post({ postId }: { postId: number | undefined }) {
|
|
129
|
+
* const { data, isLoading, isError, error } = useQuery({
|
|
130
|
+
* queryKey: ['post', postId],
|
|
131
|
+
* queryFn: () => fetchPost(postId!),
|
|
132
|
+
* enabled: postId != null,
|
|
133
|
+
* })
|
|
134
|
+
*
|
|
135
|
+
* if (postId == null) return 'Select a post'
|
|
136
|
+
* if (isLoading) return 'Loading...'
|
|
137
|
+
* if (isError) return <span>Error: {error.message}</span>
|
|
138
|
+
*
|
|
139
|
+
* return <h1>{data?.title}</h1>
|
|
140
|
+
* }
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* Seeding a detail query from an already-cached list, to skip the loading state:
|
|
145
|
+
* ```tsx
|
|
146
|
+
* import { useQuery, useQueryClient } from '@tanstack/preact-query'
|
|
147
|
+
*
|
|
148
|
+
* function Post({ postId }: { postId: number }) {
|
|
149
|
+
* const queryClient = useQueryClient()
|
|
150
|
+
*
|
|
151
|
+
* const { data } = useQuery({
|
|
152
|
+
* queryKey: ['post', postId],
|
|
153
|
+
* queryFn: () => fetchPost(postId),
|
|
154
|
+
* initialData: () =>
|
|
155
|
+
* queryClient
|
|
156
|
+
* .getQueryData<Array<Post>>(['posts'])
|
|
157
|
+
* ?.find((post) => post.id === postId),
|
|
158
|
+
* })
|
|
159
|
+
*
|
|
160
|
+
* return <h1>{data?.title}</h1>
|
|
161
|
+
* }
|
|
162
|
+
* ```
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* Paginated data, keeping the previous page's data visible while the next page loads:
|
|
166
|
+
* ```tsx
|
|
167
|
+
* import { keepPreviousData, useQuery } from '@tanstack/preact-query'
|
|
168
|
+
* import { useState } from 'preact/hooks'
|
|
169
|
+
*
|
|
170
|
+
* function Posts() {
|
|
171
|
+
* const [page, setPage] = useState(0)
|
|
172
|
+
*
|
|
173
|
+
* const { data, isPlaceholderData } = useQuery({
|
|
174
|
+
* queryKey: ['posts', page],
|
|
175
|
+
* queryFn: () => fetchPosts(page),
|
|
176
|
+
* placeholderData: keepPreviousData,
|
|
177
|
+
* })
|
|
178
|
+
*
|
|
179
|
+
* return (
|
|
180
|
+
* <div>
|
|
181
|
+
* {data?.map((post) => <p key={post.id}>{post.title}</p>)}
|
|
182
|
+
* <button
|
|
183
|
+
* disabled={isPlaceholderData}
|
|
184
|
+
* onClick={() => setPage((old) => old + 1)}
|
|
185
|
+
* >
|
|
186
|
+
* Next Page
|
|
187
|
+
* </button>
|
|
188
|
+
* </div>
|
|
189
|
+
* )
|
|
190
|
+
* }
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
7
193
|
declare function useQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): UseQueryResult<TData, TError>;
|
|
8
194
|
//#endregion
|
|
9
195
|
export { useQuery };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuery.d.ts","names":[],"sources":["../../src/useQuery.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useQuery.d.ts","names":[],"sources":["../../src/useQuery.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyCgB,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,0BAA0B,cAAc,QAAQ,OAAO,YAChE,cAAc,cACb,sBAAsB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuDhB,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,4BAA4B,cAAc,QAAQ,OAAO,YAClE,cAAc,cACb,eAAe,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4GT,SACd,wBACA,SAAS,cACT,QAAQ,cACR,kBAAkB,WAAW,UAE7B,SAAS,gBAAgB,cAAc,QAAQ,OAAO,YACtD,cAAc,cACb,eAAe,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuery.js","names":[],"sources":["../../src/useQuery.ts"],"sourcesContent":["import { QueryObserver } from '@tanstack/query-core'\nimport type { DefaultError, QueryClient, QueryKey } from '@tanstack/query-core'\n\nimport type {\n DefinedInitialDataOptions,\n UndefinedInitialDataOptions,\n} from './queryOptions'\nimport type {\n DefinedUseQueryResult,\n UseQueryOptions,\n UseQueryResult,\n} from './types'\nimport { useBaseQuery } from './useBaseQuery'\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\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\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":";;;
|
|
1
|
+
{"version":3,"file":"useQuery.js","names":[],"sources":["../../src/useQuery.ts"],"sourcesContent":["import { QueryObserver } from '@tanstack/query-core'\nimport type { DefaultError, QueryClient, QueryKey } from '@tanstack/query-core'\n\nimport type {\n DefinedInitialDataOptions,\n UndefinedInitialDataOptions,\n} from './queryOptions'\nimport type {\n DefinedUseQueryResult,\n UseQueryOptions,\n UseQueryResult,\n} from './types'\nimport { useBaseQuery } from './useBaseQuery'\n\n/**\n * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`.\n *\n * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.\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 *\n * @example\n * ```tsx\n * import { useQuery } from '@tanstack/preact-query'\n *\n * function Posts() {\n * // `data` is `Post[]`, never `undefined`, thanks to `initialData`.\n * const { data } = useQuery({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * initialData: [],\n * })\n *\n * return <>{data.map((post) => <p key={post.id}>{post.title}</p>)}</>\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 * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.\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 and no query attempt\n * has finished yet, `error` if the query attempt resulted in an error, or `success` if the query has data to\n * display. `isPending`/`isSuccess`/`isError` are derived booleans for convenience.\n *\n * @example\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/preact-query'\n *\n * const postsOptions = queryOptions({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * })\n *\n * function Posts() {\n * const { status, data, error, isFetching } = useQuery(postsOptions)\n *\n * if (status === 'pending') return 'Loading...'\n * if (status === 'error') return <span>Error: {error.message}</span>\n *\n * return (\n * <div>\n * {data.map((post) => (\n * <p key={post.id}>{post.title}</p>\n * ))}\n * <div>{isFetching ? 'Background Updating...' : ' '}</div>\n * </div>\n * )\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/preact-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 <>{data.map((post) => <p key={post.id}>{post.title}</p>)}</>\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 * @see {@link queryOptions} to share these options between `useQuery` and imperative APIs like `queryClient.query`.\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 and no query attempt\n * has finished yet, `error` if the query attempt resulted in an error, or `success` if the query has data to\n * display. `isPending`/`isSuccess`/`isError` are derived booleans for convenience.\n *\n * @example\n * ```tsx\n * import { queryOptions, useQuery } from '@tanstack/preact-query'\n *\n * const postsOptions = queryOptions({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * })\n *\n * function Posts() {\n * const { status, data, error, isFetching } = useQuery(postsOptions)\n *\n * if (status === 'pending') return 'Loading...'\n * if (status === 'error') return <span>Error: {error.message}</span>\n *\n * return (\n * <div>\n * {data.map((post) => (\n * <p key={post.id}>{post.title}</p>\n * ))}\n * <div>{isFetching ? 'Background Updating...' : ' '}</div>\n * </div>\n * )\n * }\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/preact-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 *\n * @example\n * Seeding a detail query from an already-cached list, to skip the loading state:\n * ```tsx\n * import { useQuery, useQueryClient } from '@tanstack/preact-query'\n *\n * function Post({ postId }: { postId: number }) {\n * const queryClient = useQueryClient()\n *\n * const { data } = 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 * })\n *\n * return <h1>{data?.title}</h1>\n * }\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/preact-query'\n * import { useState } from 'preact/hooks'\n *\n * function Posts() {\n * const [page, setPage] = useState(0)\n *\n * const { data, isPlaceholderData } = useQuery({\n * queryKey: ['posts', page],\n * queryFn: () => fetchPosts(page),\n * placeholderData: keepPreviousData,\n * })\n *\n * return (\n * <div>\n * {data?.map((post) => <p key={post.id}>{post.title}</p>)}\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":";;;AAsOA,SAAgB,SAAS,SAA0B,aAA2B;CAC5E,OAAO,aAAa,SAAS,eAAe,WAAW;AACzD"}
|
|
@@ -3,6 +3,62 @@ const require_suspense = require("./suspense.cjs");
|
|
|
3
3
|
const require_useBaseQuery = require("./useBaseQuery.cjs");
|
|
4
4
|
let _tanstack_query_core = require("@tanstack/query-core");
|
|
5
5
|
//#region src/useSuspenseInfiniteQuery.ts
|
|
6
|
+
/**
|
|
7
|
+
* The options for `useSuspenseInfiniteQuery` are the same as for `useInfiniteQuery`, except for `throwOnError`,
|
|
8
|
+
* `enabled`, and `placeholderData`.
|
|
9
|
+
*
|
|
10
|
+
* Caveat: cancellation does not work.
|
|
11
|
+
*
|
|
12
|
+
* @param options - The {@link UseSuspenseInfiniteQueryOptions} to use — the same options as `useInfiniteQuery`, minus the ones listed above.
|
|
13
|
+
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
14
|
+
* be used.
|
|
15
|
+
* @returns The same object as `useInfiniteQuery`, except that `data` is guaranteed to be defined,
|
|
16
|
+
* `isPlaceholderData` is missing, and `status` is either `success` or `error` (with the derived flags set
|
|
17
|
+
* accordingly).
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* import { Suspense } from 'preact/compat'
|
|
22
|
+
* import { useSuspenseInfiniteQuery } from '@tanstack/preact-query'
|
|
23
|
+
*
|
|
24
|
+
* function Projects() {
|
|
25
|
+
* // `data` is guaranteed to be defined here — no `isPending` check needed.
|
|
26
|
+
* const { data, fetchNextPage, hasNextPage, isFetching, isFetchingNextPage } =
|
|
27
|
+
* useSuspenseInfiniteQuery({
|
|
28
|
+
* queryKey: ['projects'],
|
|
29
|
+
* queryFn: ({ pageParam }) => fetchProjects(pageParam),
|
|
30
|
+
* initialPageParam: 0,
|
|
31
|
+
* getNextPageParam: (lastPage) => lastPage.nextId,
|
|
32
|
+
* })
|
|
33
|
+
*
|
|
34
|
+
* return (
|
|
35
|
+
* <div>
|
|
36
|
+
* {data.pages.map((page) =>
|
|
37
|
+
* page.projects.map((project) => <p key={project.id}>{project.name}</p>),
|
|
38
|
+
* )}
|
|
39
|
+
* <button
|
|
40
|
+
* onClick={() => fetchNextPage()}
|
|
41
|
+
* disabled={!hasNextPage || isFetching}
|
|
42
|
+
* >
|
|
43
|
+
* {isFetchingNextPage
|
|
44
|
+
* ? 'Loading more...'
|
|
45
|
+
* : hasNextPage
|
|
46
|
+
* ? 'Load More'
|
|
47
|
+
* : 'Nothing more to load'}
|
|
48
|
+
* </button>
|
|
49
|
+
* </div>
|
|
50
|
+
* )
|
|
51
|
+
* }
|
|
52
|
+
*
|
|
53
|
+
* function App() {
|
|
54
|
+
* return (
|
|
55
|
+
* <Suspense fallback={<h1>Loading projects...</h1>}>
|
|
56
|
+
* <Projects />
|
|
57
|
+
* </Suspense>
|
|
58
|
+
* )
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
6
62
|
function useSuspenseInfiniteQuery(options, queryClient) {
|
|
7
63
|
if (process.env.NODE_ENV !== "production") {
|
|
8
64
|
if (options.queryFn === _tanstack_query_core.skipToken) console.error("skipToken is not allowed for useSuspenseInfiniteQuery");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSuspenseInfiniteQuery.cjs","names":["skipToken","useBaseQuery","defaultThrowOnError","InfiniteQueryObserver"],"sources":["../../src/useSuspenseInfiniteQuery.ts"],"sourcesContent":["import { InfiniteQueryObserver, skipToken } from '@tanstack/query-core'\nimport type {\n DefaultError,\n InfiniteData,\n InfiniteQueryObserverSuccessResult,\n QueryClient,\n QueryKey,\n QueryObserver,\n} from '@tanstack/query-core'\n\nimport { defaultThrowOnError } from './suspense'\nimport type {\n UseSuspenseInfiniteQueryOptions,\n UseSuspenseInfiniteQueryResult,\n} from './types'\nimport { useBaseQuery } from './useBaseQuery'\n\nexport function useSuspenseInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UseSuspenseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: QueryClient,\n): UseSuspenseInfiniteQueryResult<TData, TError> {\n if (process.env.NODE_ENV !== 'production') {\n if ((options.queryFn as any) === skipToken) {\n console.error('skipToken is not allowed for useSuspenseInfiniteQuery')\n }\n }\n\n return useBaseQuery(\n {\n ...options,\n enabled: true,\n suspense: true,\n throwOnError: defaultThrowOnError,\n placeholderData: undefined,\n },\n InfiniteQueryObserver as typeof QueryObserver,\n queryClient,\n ) as InfiniteQueryObserverSuccessResult<TData, TError>\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSuspenseInfiniteQuery.cjs","names":["skipToken","useBaseQuery","defaultThrowOnError","InfiniteQueryObserver"],"sources":["../../src/useSuspenseInfiniteQuery.ts"],"sourcesContent":["import { InfiniteQueryObserver, skipToken } from '@tanstack/query-core'\nimport type {\n DefaultError,\n InfiniteData,\n InfiniteQueryObserverSuccessResult,\n QueryClient,\n QueryKey,\n QueryObserver,\n} from '@tanstack/query-core'\n\nimport { defaultThrowOnError } from './suspense'\nimport type {\n UseSuspenseInfiniteQueryOptions,\n UseSuspenseInfiniteQueryResult,\n} from './types'\nimport { useBaseQuery } from './useBaseQuery'\n\n/**\n * The options for `useSuspenseInfiniteQuery` are the same as for `useInfiniteQuery`, except for `throwOnError`,\n * `enabled`, and `placeholderData`.\n *\n * Caveat: cancellation does not work.\n *\n * @param options - The {@link UseSuspenseInfiniteQueryOptions} to use — the same options as `useInfiniteQuery`, minus the ones listed above.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will\n * be used.\n * @returns The same object as `useInfiniteQuery`, except that `data` is guaranteed to be defined,\n * `isPlaceholderData` is missing, and `status` is either `success` or `error` (with the derived flags set\n * accordingly).\n *\n * @example\n * ```tsx\n * import { Suspense } from 'preact/compat'\n * import { useSuspenseInfiniteQuery } from '@tanstack/preact-query'\n *\n * function Projects() {\n * // `data` is guaranteed to be defined here — no `isPending` check needed.\n * const { data, fetchNextPage, hasNextPage, isFetching, isFetchingNextPage } =\n * useSuspenseInfiniteQuery({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * return (\n * <div>\n * {data.pages.map((page) =>\n * page.projects.map((project) => <p key={project.id}>{project.name}</p>),\n * )}\n * <button\n * onClick={() => fetchNextPage()}\n * disabled={!hasNextPage || isFetching}\n * >\n * {isFetchingNextPage\n * ? 'Loading more...'\n * : hasNextPage\n * ? 'Load More'\n * : 'Nothing more to load'}\n * </button>\n * </div>\n * )\n * }\n *\n * function App() {\n * return (\n * <Suspense fallback={<h1>Loading projects...</h1>}>\n * <Projects />\n * </Suspense>\n * )\n * }\n * ```\n */\nexport function useSuspenseInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UseSuspenseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: QueryClient,\n): UseSuspenseInfiniteQueryResult<TData, TError> {\n if (process.env.NODE_ENV !== 'production') {\n if ((options.queryFn as any) === skipToken) {\n console.error('skipToken is not allowed for useSuspenseInfiniteQuery')\n }\n }\n\n return useBaseQuery(\n {\n ...options,\n enabled: true,\n suspense: true,\n throwOnError: defaultThrowOnError,\n placeholderData: undefined,\n },\n InfiniteQueryObserver as typeof QueryObserver,\n queryClient,\n ) as InfiniteQueryObserverSuccessResult<TData, TError>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,SAAgB,yBAOd,SAOA,aAC+C;CAC/C,IAAI,QAAQ,IAAI,aAAa,cACtB;MAAA,QAAQ,YAAoBA,qBAAAA,WAC/B,QAAQ,MAAM,uDAAuD;CAAA;CAIzE,OAAOC,qBAAAA,aACL;EACE,GAAG;EACH,SAAS;EACT,UAAU;EACV,cAAcC,iBAAAA;EACd,iBAAiB,KAAA;CACnB,GACAC,qBAAAA,uBACA,WACF;AACF"}
|
|
@@ -1,6 +1,62 @@
|
|
|
1
1
|
import { UseSuspenseInfiniteQueryOptions, UseSuspenseInfiniteQueryResult } from "./types.cjs";
|
|
2
2
|
import { DefaultError, InfiniteData, QueryClient, QueryKey } from "@tanstack/query-core";
|
|
3
3
|
//#region src/useSuspenseInfiniteQuery.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The options for `useSuspenseInfiniteQuery` are the same as for `useInfiniteQuery`, except for `throwOnError`,
|
|
6
|
+
* `enabled`, and `placeholderData`.
|
|
7
|
+
*
|
|
8
|
+
* Caveat: cancellation does not work.
|
|
9
|
+
*
|
|
10
|
+
* @param options - The {@link UseSuspenseInfiniteQueryOptions} to use — the same options as `useInfiniteQuery`, minus the ones listed above.
|
|
11
|
+
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
12
|
+
* be used.
|
|
13
|
+
* @returns The same object as `useInfiniteQuery`, except that `data` is guaranteed to be defined,
|
|
14
|
+
* `isPlaceholderData` is missing, and `status` is either `success` or `error` (with the derived flags set
|
|
15
|
+
* accordingly).
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* import { Suspense } from 'preact/compat'
|
|
20
|
+
* import { useSuspenseInfiniteQuery } from '@tanstack/preact-query'
|
|
21
|
+
*
|
|
22
|
+
* function Projects() {
|
|
23
|
+
* // `data` is guaranteed to be defined here — no `isPending` check needed.
|
|
24
|
+
* const { data, fetchNextPage, hasNextPage, isFetching, isFetchingNextPage } =
|
|
25
|
+
* useSuspenseInfiniteQuery({
|
|
26
|
+
* queryKey: ['projects'],
|
|
27
|
+
* queryFn: ({ pageParam }) => fetchProjects(pageParam),
|
|
28
|
+
* initialPageParam: 0,
|
|
29
|
+
* getNextPageParam: (lastPage) => lastPage.nextId,
|
|
30
|
+
* })
|
|
31
|
+
*
|
|
32
|
+
* return (
|
|
33
|
+
* <div>
|
|
34
|
+
* {data.pages.map((page) =>
|
|
35
|
+
* page.projects.map((project) => <p key={project.id}>{project.name}</p>),
|
|
36
|
+
* )}
|
|
37
|
+
* <button
|
|
38
|
+
* onClick={() => fetchNextPage()}
|
|
39
|
+
* disabled={!hasNextPage || isFetching}
|
|
40
|
+
* >
|
|
41
|
+
* {isFetchingNextPage
|
|
42
|
+
* ? 'Loading more...'
|
|
43
|
+
* : hasNextPage
|
|
44
|
+
* ? 'Load More'
|
|
45
|
+
* : 'Nothing more to load'}
|
|
46
|
+
* </button>
|
|
47
|
+
* </div>
|
|
48
|
+
* )
|
|
49
|
+
* }
|
|
50
|
+
*
|
|
51
|
+
* function App() {
|
|
52
|
+
* return (
|
|
53
|
+
* <Suspense fallback={<h1>Loading projects...</h1>}>
|
|
54
|
+
* <Projects />
|
|
55
|
+
* </Suspense>
|
|
56
|
+
* )
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
4
60
|
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>;
|
|
5
61
|
//#endregion
|
|
6
62
|
export { useSuspenseInfiniteQuery };
|
|
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyEgB,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,62 @@
|
|
|
1
1
|
import { UseSuspenseInfiniteQueryOptions, UseSuspenseInfiniteQueryResult } from "./types.js";
|
|
2
2
|
import { DefaultError, InfiniteData, QueryClient, QueryKey } from "@tanstack/query-core";
|
|
3
3
|
//#region src/useSuspenseInfiniteQuery.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The options for `useSuspenseInfiniteQuery` are the same as for `useInfiniteQuery`, except for `throwOnError`,
|
|
6
|
+
* `enabled`, and `placeholderData`.
|
|
7
|
+
*
|
|
8
|
+
* Caveat: cancellation does not work.
|
|
9
|
+
*
|
|
10
|
+
* @param options - The {@link UseSuspenseInfiniteQueryOptions} to use — the same options as `useInfiniteQuery`, minus the ones listed above.
|
|
11
|
+
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
12
|
+
* be used.
|
|
13
|
+
* @returns The same object as `useInfiniteQuery`, except that `data` is guaranteed to be defined,
|
|
14
|
+
* `isPlaceholderData` is missing, and `status` is either `success` or `error` (with the derived flags set
|
|
15
|
+
* accordingly).
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* import { Suspense } from 'preact/compat'
|
|
20
|
+
* import { useSuspenseInfiniteQuery } from '@tanstack/preact-query'
|
|
21
|
+
*
|
|
22
|
+
* function Projects() {
|
|
23
|
+
* // `data` is guaranteed to be defined here — no `isPending` check needed.
|
|
24
|
+
* const { data, fetchNextPage, hasNextPage, isFetching, isFetchingNextPage } =
|
|
25
|
+
* useSuspenseInfiniteQuery({
|
|
26
|
+
* queryKey: ['projects'],
|
|
27
|
+
* queryFn: ({ pageParam }) => fetchProjects(pageParam),
|
|
28
|
+
* initialPageParam: 0,
|
|
29
|
+
* getNextPageParam: (lastPage) => lastPage.nextId,
|
|
30
|
+
* })
|
|
31
|
+
*
|
|
32
|
+
* return (
|
|
33
|
+
* <div>
|
|
34
|
+
* {data.pages.map((page) =>
|
|
35
|
+
* page.projects.map((project) => <p key={project.id}>{project.name}</p>),
|
|
36
|
+
* )}
|
|
37
|
+
* <button
|
|
38
|
+
* onClick={() => fetchNextPage()}
|
|
39
|
+
* disabled={!hasNextPage || isFetching}
|
|
40
|
+
* >
|
|
41
|
+
* {isFetchingNextPage
|
|
42
|
+
* ? 'Loading more...'
|
|
43
|
+
* : hasNextPage
|
|
44
|
+
* ? 'Load More'
|
|
45
|
+
* : 'Nothing more to load'}
|
|
46
|
+
* </button>
|
|
47
|
+
* </div>
|
|
48
|
+
* )
|
|
49
|
+
* }
|
|
50
|
+
*
|
|
51
|
+
* function App() {
|
|
52
|
+
* return (
|
|
53
|
+
* <Suspense fallback={<h1>Loading projects...</h1>}>
|
|
54
|
+
* <Projects />
|
|
55
|
+
* </Suspense>
|
|
56
|
+
* )
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
4
60
|
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>;
|
|
5
61
|
//#endregion
|
|
6
62
|
export { useSuspenseInfiniteQuery };
|
|
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyEgB,yBACd,cACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,sBAEA,SAAS,gCACP,cACA,QACA,OACA,WACA,aAEF,cAAc,cACb,+BAA+B,OAAO"}
|