import { UseSuspenseInfiniteQueryOptions, UseSuspenseInfiniteQueryResult } from "./types.cjs"; import { DefaultError, InfiniteData, QueryClient, QueryKey } from "@tanstack/query-core"; //#region src/useSuspenseInfiniteQuery.d.ts /** * The options for `useSuspenseInfiniteQuery` are the same as for `useInfiniteQuery`, except for `throwOnError`, * `enabled`, and `placeholderData`. * * Caveat: cancellation does not work. * * @remarks Multiple suspenseful query calls in the same component suspend serially, causing a request * waterfall — each one blocks rendering until it resolves, so the next doesn't even start fetching until * then. There's no way to parallelize multiple infinite queries under Suspense. Also keep in mind that * imperative fetch calls, such as `fetchNextPage`, may interfere with the default refetch behavior, * resulting in outdated data. Make sure to call these functions only in response to user actions, or add * conditions like `hasNextPage && !isFetching`. * @see {@link useInfiniteQuery} for the non-Suspense version of this hook. * @param options - The {@link UseSuspenseInfiniteQueryOptions} to use — the same options as `useInfiniteQuery`, minus the ones listed above. * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will * be used. * @returns The same object as `useInfiniteQuery`, except that `data` is guaranteed to be defined, * `isPlaceholderData` is missing, and `status` is either `success` or `error` (with the derived flags set * accordingly). * * @example * The query error is thrown if a fetch fails and no cached data exists yet, so an error boundary is * required around ``. A failed background refetch instead continues to render the cached data. * Use {@link QueryErrorResetBoundary} to let the user retry after such an error: * ```tsx * import { Suspense } from 'react' * import { ErrorBoundary } from 'react-error-boundary' * import { * QueryErrorResetBoundary, * useSuspenseInfiniteQuery, * } from '@tanstack/react-query' * * function Projects() { * // `data` is guaranteed to be defined here — no `isPending` check needed. * const { data, fetchNextPage, hasNextPage, isFetching, isFetchingNextPage } = * useSuspenseInfiniteQuery({ * queryKey: ['projects'], * queryFn: ({ pageParam }) => fetchProjects(pageParam), * initialPageParam: 0, * getNextPageParam: (lastPage) => lastPage.nextId, * }) * * return ( *
* * *
* ) * } * * function App() { * return ( * * {({ reset }) => ( * ( *
* There was an error! * *
* )} * > * Loading projects...}> * * *
* )} *
* ) * } * ``` */ declare function useSuspenseInfiniteQuery, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: UseSuspenseInfiniteQueryOptions, queryClient?: QueryClient): UseSuspenseInfiniteQueryResult; //#endregion export { useSuspenseInfiniteQuery }; //# sourceMappingURL=useSuspenseInfiniteQuery.d.cts.map