@tanstack/react-query 5.104.0 → 5.104.2
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.cjs.map +1 -1
- package/build/legacy/HydrationBoundary.d.cts +2 -3
- package/build/legacy/HydrationBoundary.d.cts.map +1 -1
- package/build/legacy/HydrationBoundary.d.ts +2 -3
- package/build/legacy/HydrationBoundary.d.ts.map +1 -1
- package/build/legacy/HydrationBoundary.js +2 -3
- package/build/legacy/HydrationBoundary.js.map +1 -1
- package/build/legacy/IsRestoringProvider.cjs +0 -1
- package/build/legacy/IsRestoringProvider.cjs.map +1 -1
- package/build/legacy/IsRestoringProvider.d.cts +0 -1
- package/build/legacy/IsRestoringProvider.d.cts.map +1 -1
- package/build/legacy/IsRestoringProvider.d.ts +0 -1
- package/build/legacy/IsRestoringProvider.d.ts.map +1 -1
- package/build/legacy/IsRestoringProvider.js +0 -1
- package/build/legacy/IsRestoringProvider.js.map +1 -1
- package/build/legacy/QueryClientProvider.cjs +3 -4
- package/build/legacy/QueryClientProvider.cjs.map +1 -1
- package/build/legacy/QueryClientProvider.d.cts +3 -4
- package/build/legacy/QueryClientProvider.d.cts.map +1 -1
- package/build/legacy/QueryClientProvider.d.ts +3 -4
- package/build/legacy/QueryClientProvider.d.ts.map +1 -1
- package/build/legacy/QueryClientProvider.js +3 -4
- package/build/legacy/QueryClientProvider.js.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.cjs +5 -5
- package/build/legacy/QueryErrorResetBoundary.cjs.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.d.cts +23 -5
- package/build/legacy/QueryErrorResetBoundary.d.cts.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.d.ts +23 -5
- package/build/legacy/QueryErrorResetBoundary.d.ts.map +1 -1
- package/build/legacy/QueryErrorResetBoundary.js +5 -5
- package/build/legacy/QueryErrorResetBoundary.js.map +1 -1
- package/build/legacy/errorBoundaryUtils.cjs +21 -0
- package/build/legacy/errorBoundaryUtils.cjs.map +1 -1
- package/build/legacy/errorBoundaryUtils.d.cts +21 -0
- package/build/legacy/errorBoundaryUtils.d.cts.map +1 -1
- package/build/legacy/errorBoundaryUtils.d.ts +21 -0
- package/build/legacy/errorBoundaryUtils.d.ts.map +1 -1
- package/build/legacy/errorBoundaryUtils.js +21 -0
- package/build/legacy/errorBoundaryUtils.js.map +1 -1
- package/build/legacy/infiniteQueryOptions.cjs.map +1 -1
- package/build/legacy/infiniteQueryOptions.d.cts +5 -16
- package/build/legacy/infiniteQueryOptions.d.cts.map +1 -1
- package/build/legacy/infiniteQueryOptions.d.ts +5 -16
- 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 +2 -6
- package/build/legacy/mutationOptions.d.cts.map +1 -1
- package/build/legacy/mutationOptions.d.ts +2 -6
- 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 +6 -16
- package/build/legacy/queryOptions.d.cts.map +1 -1
- package/build/legacy/queryOptions.d.ts +6 -16
- package/build/legacy/queryOptions.d.ts.map +1 -1
- package/build/legacy/queryOptions.js.map +1 -1
- package/build/legacy/suspense.cjs +27 -0
- package/build/legacy/suspense.cjs.map +1 -1
- package/build/legacy/suspense.d.cts +27 -0
- package/build/legacy/suspense.d.cts.map +1 -1
- package/build/legacy/suspense.d.ts +27 -0
- package/build/legacy/suspense.d.ts.map +1 -1
- package/build/legacy/suspense.js +27 -0
- package/build/legacy/suspense.js.map +1 -1
- package/build/legacy/types.cjs.map +1 -1
- package/build/legacy/types.d.cts +2 -22
- package/build/legacy/types.d.cts.map +1 -1
- package/build/legacy/types.d.ts +2 -22
- package/build/legacy/types.d.ts.map +1 -1
- package/build/legacy/types.js.map +1 -1
- package/build/legacy/useBaseQuery.cjs +13 -0
- package/build/legacy/useBaseQuery.cjs.map +1 -1
- package/build/legacy/useBaseQuery.d.cts +13 -0
- package/build/legacy/useBaseQuery.d.cts.map +1 -1
- package/build/legacy/useBaseQuery.d.ts +13 -0
- package/build/legacy/useBaseQuery.d.ts.map +1 -1
- package/build/legacy/useBaseQuery.js +13 -0
- package/build/legacy/useBaseQuery.js.map +1 -1
- package/build/legacy/useInfiniteQuery.cjs.map +1 -1
- package/build/legacy/useInfiniteQuery.d.cts +12 -21
- package/build/legacy/useInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/useInfiniteQuery.d.ts +12 -21
- package/build/legacy/useInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/useInfiniteQuery.js.map +1 -1
- package/build/legacy/useIsFetching.cjs +0 -3
- package/build/legacy/useIsFetching.cjs.map +1 -1
- package/build/legacy/useIsFetching.d.cts +0 -3
- package/build/legacy/useIsFetching.d.cts.map +1 -1
- package/build/legacy/useIsFetching.d.ts +0 -3
- package/build/legacy/useIsFetching.d.ts.map +1 -1
- package/build/legacy/useIsFetching.js +0 -3
- package/build/legacy/useIsFetching.js.map +1 -1
- package/build/legacy/useMutation.cjs +4 -8
- package/build/legacy/useMutation.cjs.map +1 -1
- package/build/legacy/useMutation.d.cts +4 -8
- package/build/legacy/useMutation.d.cts.map +1 -1
- package/build/legacy/useMutation.d.ts +4 -8
- package/build/legacy/useMutation.d.ts.map +1 -1
- package/build/legacy/useMutation.js +4 -8
- package/build/legacy/useMutation.js.map +1 -1
- package/build/legacy/useMutationState.cjs +13 -12
- package/build/legacy/useMutationState.cjs.map +1 -1
- package/build/legacy/useMutationState.d.cts +0 -6
- package/build/legacy/useMutationState.d.cts.map +1 -1
- package/build/legacy/useMutationState.d.ts +0 -6
- package/build/legacy/useMutationState.d.ts.map +1 -1
- package/build/legacy/useMutationState.js +13 -12
- package/build/legacy/useMutationState.js.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.cjs +0 -3
- package/build/legacy/usePrefetchInfiniteQuery.cjs.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.cts +0 -3
- package/build/legacy/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.ts +0 -3
- package/build/legacy/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.js +0 -3
- package/build/legacy/usePrefetchInfiniteQuery.js.map +1 -1
- package/build/legacy/usePrefetchQuery.cjs +0 -3
- package/build/legacy/usePrefetchQuery.cjs.map +1 -1
- package/build/legacy/usePrefetchQuery.d.cts +0 -3
- package/build/legacy/usePrefetchQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchQuery.d.ts +0 -3
- package/build/legacy/usePrefetchQuery.d.ts.map +1 -1
- package/build/legacy/usePrefetchQuery.js +0 -3
- package/build/legacy/usePrefetchQuery.js.map +1 -1
- package/build/legacy/useQueries.cjs +7 -8
- package/build/legacy/useQueries.cjs.map +1 -1
- package/build/legacy/useQueries.d.cts +7 -11
- package/build/legacy/useQueries.d.cts.map +1 -1
- package/build/legacy/useQueries.d.ts +7 -11
- package/build/legacy/useQueries.d.ts.map +1 -1
- package/build/legacy/useQueries.js +7 -8
- package/build/legacy/useQueries.js.map +1 -1
- package/build/legacy/useQuery.cjs.map +1 -1
- package/build/legacy/useQuery.d.cts +8 -13
- package/build/legacy/useQuery.d.cts.map +1 -1
- package/build/legacy/useQuery.d.ts +8 -13
- package/build/legacy/useQuery.d.ts.map +1 -1
- package/build/legacy/useQuery.js.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.cjs +6 -8
- package/build/legacy/useSuspenseInfiniteQuery.cjs.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.d.cts +6 -8
- package/build/legacy/useSuspenseInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.d.ts +6 -8
- package/build/legacy/useSuspenseInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/useSuspenseInfiniteQuery.js +6 -8
- package/build/legacy/useSuspenseInfiniteQuery.js.map +1 -1
- package/build/legacy/useSuspenseQueries.cjs.map +1 -1
- package/build/legacy/useSuspenseQueries.d.cts +0 -9
- package/build/legacy/useSuspenseQueries.d.cts.map +1 -1
- package/build/legacy/useSuspenseQueries.d.ts +0 -9
- package/build/legacy/useSuspenseQueries.d.ts.map +1 -1
- package/build/legacy/useSuspenseQueries.js.map +1 -1
- package/build/legacy/useSuspenseQuery.cjs +4 -6
- package/build/legacy/useSuspenseQuery.cjs.map +1 -1
- package/build/legacy/useSuspenseQuery.d.cts +4 -6
- package/build/legacy/useSuspenseQuery.d.cts.map +1 -1
- package/build/legacy/useSuspenseQuery.d.ts +4 -6
- package/build/legacy/useSuspenseQuery.d.ts.map +1 -1
- package/build/legacy/useSuspenseQuery.js +4 -6
- package/build/legacy/useSuspenseQuery.js.map +1 -1
- package/build/modern/HydrationBoundary.cjs +2 -3
- package/build/modern/HydrationBoundary.cjs.map +1 -1
- package/build/modern/HydrationBoundary.d.cts +2 -3
- package/build/modern/HydrationBoundary.d.cts.map +1 -1
- package/build/modern/HydrationBoundary.d.ts +2 -3
- package/build/modern/HydrationBoundary.d.ts.map +1 -1
- package/build/modern/HydrationBoundary.js +2 -3
- package/build/modern/HydrationBoundary.js.map +1 -1
- package/build/modern/IsRestoringProvider.cjs +0 -1
- package/build/modern/IsRestoringProvider.cjs.map +1 -1
- package/build/modern/IsRestoringProvider.d.cts +0 -1
- package/build/modern/IsRestoringProvider.d.cts.map +1 -1
- package/build/modern/IsRestoringProvider.d.ts +0 -1
- package/build/modern/IsRestoringProvider.d.ts.map +1 -1
- package/build/modern/IsRestoringProvider.js +0 -1
- package/build/modern/IsRestoringProvider.js.map +1 -1
- package/build/modern/QueryClientProvider.cjs +3 -4
- package/build/modern/QueryClientProvider.cjs.map +1 -1
- package/build/modern/QueryClientProvider.d.cts +3 -4
- package/build/modern/QueryClientProvider.d.cts.map +1 -1
- package/build/modern/QueryClientProvider.d.ts +3 -4
- package/build/modern/QueryClientProvider.d.ts.map +1 -1
- package/build/modern/QueryClientProvider.js +3 -4
- package/build/modern/QueryClientProvider.js.map +1 -1
- package/build/modern/QueryErrorResetBoundary.cjs +5 -5
- package/build/modern/QueryErrorResetBoundary.cjs.map +1 -1
- package/build/modern/QueryErrorResetBoundary.d.cts +23 -5
- package/build/modern/QueryErrorResetBoundary.d.cts.map +1 -1
- package/build/modern/QueryErrorResetBoundary.d.ts +23 -5
- package/build/modern/QueryErrorResetBoundary.d.ts.map +1 -1
- package/build/modern/QueryErrorResetBoundary.js +5 -5
- package/build/modern/QueryErrorResetBoundary.js.map +1 -1
- package/build/modern/errorBoundaryUtils.cjs +21 -0
- package/build/modern/errorBoundaryUtils.cjs.map +1 -1
- package/build/modern/errorBoundaryUtils.d.cts +21 -0
- package/build/modern/errorBoundaryUtils.d.cts.map +1 -1
- package/build/modern/errorBoundaryUtils.d.ts +21 -0
- package/build/modern/errorBoundaryUtils.d.ts.map +1 -1
- package/build/modern/errorBoundaryUtils.js +21 -0
- package/build/modern/errorBoundaryUtils.js.map +1 -1
- package/build/modern/infiniteQueryOptions.cjs.map +1 -1
- package/build/modern/infiniteQueryOptions.d.cts +5 -16
- package/build/modern/infiniteQueryOptions.d.cts.map +1 -1
- package/build/modern/infiniteQueryOptions.d.ts +5 -16
- 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 +2 -6
- package/build/modern/mutationOptions.d.cts.map +1 -1
- package/build/modern/mutationOptions.d.ts +2 -6
- 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 +6 -16
- package/build/modern/queryOptions.d.cts.map +1 -1
- package/build/modern/queryOptions.d.ts +6 -16
- package/build/modern/queryOptions.d.ts.map +1 -1
- package/build/modern/queryOptions.js.map +1 -1
- package/build/modern/suspense.cjs +27 -0
- package/build/modern/suspense.cjs.map +1 -1
- package/build/modern/suspense.d.cts +27 -0
- package/build/modern/suspense.d.cts.map +1 -1
- package/build/modern/suspense.d.ts +27 -0
- package/build/modern/suspense.d.ts.map +1 -1
- package/build/modern/suspense.js +27 -0
- package/build/modern/suspense.js.map +1 -1
- package/build/modern/types.cjs.map +1 -1
- package/build/modern/types.d.cts +2 -22
- package/build/modern/types.d.cts.map +1 -1
- package/build/modern/types.d.ts +2 -22
- package/build/modern/types.d.ts.map +1 -1
- package/build/modern/types.js.map +1 -1
- package/build/modern/useBaseQuery.cjs +13 -0
- package/build/modern/useBaseQuery.cjs.map +1 -1
- package/build/modern/useBaseQuery.d.cts +13 -0
- package/build/modern/useBaseQuery.d.cts.map +1 -1
- package/build/modern/useBaseQuery.d.ts +13 -0
- package/build/modern/useBaseQuery.d.ts.map +1 -1
- package/build/modern/useBaseQuery.js +13 -0
- package/build/modern/useBaseQuery.js.map +1 -1
- package/build/modern/useInfiniteQuery.cjs.map +1 -1
- package/build/modern/useInfiniteQuery.d.cts +12 -21
- package/build/modern/useInfiniteQuery.d.cts.map +1 -1
- package/build/modern/useInfiniteQuery.d.ts +12 -21
- package/build/modern/useInfiniteQuery.d.ts.map +1 -1
- package/build/modern/useInfiniteQuery.js.map +1 -1
- package/build/modern/useIsFetching.cjs +0 -3
- package/build/modern/useIsFetching.cjs.map +1 -1
- package/build/modern/useIsFetching.d.cts +0 -3
- package/build/modern/useIsFetching.d.cts.map +1 -1
- package/build/modern/useIsFetching.d.ts +0 -3
- package/build/modern/useIsFetching.d.ts.map +1 -1
- package/build/modern/useIsFetching.js +0 -3
- package/build/modern/useIsFetching.js.map +1 -1
- package/build/modern/useMutation.cjs +4 -8
- package/build/modern/useMutation.cjs.map +1 -1
- package/build/modern/useMutation.d.cts +4 -8
- package/build/modern/useMutation.d.cts.map +1 -1
- package/build/modern/useMutation.d.ts +4 -8
- package/build/modern/useMutation.d.ts.map +1 -1
- package/build/modern/useMutation.js +4 -8
- package/build/modern/useMutation.js.map +1 -1
- package/build/modern/useMutationState.cjs +13 -12
- package/build/modern/useMutationState.cjs.map +1 -1
- package/build/modern/useMutationState.d.cts +0 -6
- package/build/modern/useMutationState.d.cts.map +1 -1
- package/build/modern/useMutationState.d.ts +0 -6
- package/build/modern/useMutationState.d.ts.map +1 -1
- package/build/modern/useMutationState.js +13 -12
- package/build/modern/useMutationState.js.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.cjs +0 -3
- package/build/modern/usePrefetchInfiniteQuery.cjs.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.cts +0 -3
- package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.ts +0 -3
- package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.js +0 -3
- package/build/modern/usePrefetchInfiniteQuery.js.map +1 -1
- package/build/modern/usePrefetchQuery.cjs +0 -3
- package/build/modern/usePrefetchQuery.cjs.map +1 -1
- package/build/modern/usePrefetchQuery.d.cts +0 -3
- package/build/modern/usePrefetchQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchQuery.d.ts +0 -3
- package/build/modern/usePrefetchQuery.d.ts.map +1 -1
- package/build/modern/usePrefetchQuery.js +0 -3
- package/build/modern/usePrefetchQuery.js.map +1 -1
- package/build/modern/useQueries.cjs +7 -8
- package/build/modern/useQueries.cjs.map +1 -1
- package/build/modern/useQueries.d.cts +7 -11
- package/build/modern/useQueries.d.cts.map +1 -1
- package/build/modern/useQueries.d.ts +7 -11
- package/build/modern/useQueries.d.ts.map +1 -1
- package/build/modern/useQueries.js +7 -8
- package/build/modern/useQueries.js.map +1 -1
- package/build/modern/useQuery.cjs.map +1 -1
- package/build/modern/useQuery.d.cts +8 -13
- package/build/modern/useQuery.d.cts.map +1 -1
- package/build/modern/useQuery.d.ts +8 -13
- package/build/modern/useQuery.d.ts.map +1 -1
- package/build/modern/useQuery.js.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.cjs +6 -8
- package/build/modern/useSuspenseInfiniteQuery.cjs.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.d.cts +6 -8
- package/build/modern/useSuspenseInfiniteQuery.d.cts.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.d.ts +6 -8
- package/build/modern/useSuspenseInfiniteQuery.d.ts.map +1 -1
- package/build/modern/useSuspenseInfiniteQuery.js +6 -8
- package/build/modern/useSuspenseInfiniteQuery.js.map +1 -1
- package/build/modern/useSuspenseQueries.cjs.map +1 -1
- package/build/modern/useSuspenseQueries.d.cts +0 -9
- package/build/modern/useSuspenseQueries.d.cts.map +1 -1
- package/build/modern/useSuspenseQueries.d.ts +0 -9
- package/build/modern/useSuspenseQueries.d.ts.map +1 -1
- package/build/modern/useSuspenseQueries.js.map +1 -1
- package/build/modern/useSuspenseQuery.cjs +4 -6
- package/build/modern/useSuspenseQuery.cjs.map +1 -1
- package/build/modern/useSuspenseQuery.d.cts +4 -6
- package/build/modern/useSuspenseQuery.d.cts.map +1 -1
- package/build/modern/useSuspenseQuery.d.ts +4 -6
- package/build/modern/useSuspenseQuery.d.ts.map +1 -1
- package/build/modern/useSuspenseQuery.js +4 -6
- package/build/modern/useSuspenseQuery.js.map +1 -1
- package/package.json +10 -8
- package/src/HydrationBoundary.tsx +4 -5
- package/src/IsRestoringProvider.ts +0 -1
- package/src/QueryClientProvider.tsx +3 -4
- package/src/QueryErrorResetBoundary.tsx +30 -6
- package/src/errorBoundaryUtils.ts +21 -0
- package/src/infiniteQueryOptions.ts +5 -16
- package/src/mutationOptions.ts +2 -6
- package/src/queryOptions.ts +8 -17
- package/src/suspense.ts +29 -1
- package/src/types.ts +2 -22
- package/src/useBaseQuery.ts +13 -0
- package/src/useInfiniteQuery.ts +12 -21
- package/src/useIsFetching.ts +0 -3
- package/src/useMutation.ts +4 -8
- package/src/useMutationState.ts +15 -14
- package/src/usePrefetchInfiniteQuery.tsx +0 -3
- package/src/usePrefetchQuery.tsx +0 -3
- package/src/useQueries.ts +7 -11
- package/src/useQuery.ts +8 -13
- package/src/useSuspenseInfiniteQuery.ts +6 -8
- package/src/useSuspenseQueries.ts +0 -9
- package/src/useSuspenseQuery.ts +4 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HydrationBoundary.cjs","names":["useQueryClient","React"],"sources":["../../src/HydrationBoundary.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport { hydrate } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\nimport type {\n DehydratedState,\n HydrateOptions,\n OmitKeyof,\n QueryClient,\n} from '@tanstack/query-core'\n\n/**\n * The props accepted by `HydrationBoundary`.\n */\nexport interface HydrationBoundaryProps {\n /**\n * The state to hydrate.\n */\n state: DehydratedState | null | undefined\n /**\n * Optional. Note: unlike `hydrate`, `mutations` cannot be set here.\n */\n options?: OmitKeyof<HydrateOptions, 'defaultOptions'> & {\n defaultOptions?: OmitKeyof<\n Exclude<HydrateOptions['defaultOptions'], undefined>,\n 'mutations'\n >\n }\n /**\n * The components to render — always rendered unconditionally, not gated on hydration. New queries are\n * hydrated into the cache during render; for queries that already exist in the cache, only newer dehydrated\n * data is hydrated, and that happens in an effect after commit, so `children` may render briefly before it\n * lands.\n */\n children?: React.ReactNode\n /**\n * Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used.\n */\n queryClient?: QueryClient\n}\n\n/**\n * `HydrationBoundary` adds a previously dehydrated state into the `queryClient` that would be returned by\n * `useQueryClient()`. If the client already contains data, the new queries will be intelligently merged based on\n * update timestamp.\n *\n * Note: Only `queries` can be dehydrated with an `HydrationBoundary`.\n
|
|
1
|
+
{"version":3,"file":"HydrationBoundary.cjs","names":["useQueryClient","React"],"sources":["../../src/HydrationBoundary.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport { hydrate } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\nimport type {\n DehydratedState,\n HydrateOptions,\n OmitKeyof,\n QueryClient,\n} from '@tanstack/query-core'\n\n/**\n * The props accepted by `HydrationBoundary`.\n */\nexport interface HydrationBoundaryProps {\n /**\n * The state to hydrate.\n */\n state: DehydratedState | null | undefined\n /**\n * Optional. Note: unlike `hydrate`, `mutations` cannot be set here.\n */\n options?: OmitKeyof<HydrateOptions, 'defaultOptions'> & {\n defaultOptions?: OmitKeyof<\n Exclude<HydrateOptions['defaultOptions'], undefined>,\n 'mutations'\n >\n }\n /**\n * The components to render — always rendered unconditionally, not gated on hydration. New queries are\n * hydrated into the cache during render; for queries that already exist in the cache, only newer dehydrated\n * data is hydrated, and that happens in an effect after commit, so `children` may render briefly before it\n * lands.\n */\n children?: React.ReactNode\n /**\n * Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used.\n */\n queryClient?: QueryClient\n}\n\n/**\n * `HydrationBoundary` adds a previously dehydrated state into the `queryClient` that would be returned by\n * `useQueryClient()`. If the client already contains data, the new queries will be intelligently merged based on\n * update timestamp.\n *\n * Note: Only `queries` can be dehydrated with an `HydrationBoundary`.\n * @param props - The dehydrated `state` to hydrate, the hydrate `options`, an optional custom\n * `queryClient`, and the `children` to render.\n * @returns The provided `children`, rendered unconditionally. New queries in `state` are hydrated into the\n * cache during render; for queries already in the cache, only newer dehydrated data is hydrated, in an effect\n * after commit.\n * @example\n * ```tsx\n * import { HydrationBoundary } from '@tanstack/react-query'\n *\n * function App() {\n * return <HydrationBoundary state={dehydratedState}>...</HydrationBoundary>\n * }\n * ```\n * @example\n * Server-side prefetch handed off to the client via `dehydrate`:\n * ```tsx\n * import { HydrationBoundary, dehydrate, noop } from '@tanstack/react-query'\n *\n * async function ServerComponent() {\n * const queryClient = getQueryClient()\n *\n * await queryClient\n * .query({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * })\n * .catch(noop)\n *\n * return (\n * <HydrationBoundary state={dehydrate(queryClient)}>\n * <Posts />\n * </HydrationBoundary>\n * )\n * }\n * ```\n */\nexport const HydrationBoundary = ({\n children,\n options = {},\n state,\n queryClient,\n}: HydrationBoundaryProps) => {\n const client = useQueryClient(queryClient)\n\n const optionsRef = React.useRef(options)\n React.useEffect(() => {\n optionsRef.current = options\n })\n\n // This useMemo is for performance reasons only, everything inside it must\n // be safe to run in every render and code here should be read as \"in render\".\n //\n // This code needs to happen during the render phase, because after initial\n // SSR, hydration needs to happen _before_ children render. Also, if hydrating\n // during a transition, we want to hydrate as much as is safe in render so\n // we can prerender as much as possible.\n //\n // For any queries that already exist in the cache, we want to hold back on\n // hydrating until _after_ the render phase. The reason for this is that during\n // transitions, we don't want the existing queries and observers to update to\n // the new data on the current page, only _after_ the transition is committed.\n // If the transition is aborted, we will have hydrated any _new_ queries, but\n // we throw away the fresh data for any existing ones to avoid unexpectedly\n // updating the UI.\n const hydrationQueue: DehydratedState['queries'] | undefined =\n React.useMemo(() => {\n if (state) {\n if (typeof state !== 'object') {\n return\n }\n\n const queryCache = client.getQueryCache()\n // State is supplied from the outside and we might as well fail\n // gracefully if it has the wrong shape, so while we type `queries`\n // as required, we still provide a fallback.\n // oxlint-disable-next-line typescript/no-unnecessary-condition\n const queries = state.queries || []\n\n const newQueries: DehydratedState['queries'] = []\n const existingQueries: DehydratedState['queries'] = []\n for (const dehydratedQuery of queries) {\n const existingQuery = queryCache.get(dehydratedQuery.queryHash)\n\n if (!existingQuery) {\n newQueries.push(dehydratedQuery)\n } else {\n const hydrationIsNewer =\n dehydratedQuery.state.dataUpdatedAt >\n existingQuery.state.dataUpdatedAt ||\n (dehydratedQuery.promise &&\n existingQuery.state.status !== 'pending' &&\n existingQuery.state.fetchStatus !== 'fetching' &&\n dehydratedQuery.dehydratedAt >\n existingQuery.state.dataUpdatedAt)\n\n if (hydrationIsNewer) {\n existingQueries.push(dehydratedQuery)\n }\n }\n }\n\n if (newQueries.length > 0) {\n // It's actually fine to call this with queries/state that already exists\n // in the cache, or is older. hydrate() is idempotent for queries.\n // oxlint-disable-next-line react-hooks-js/refs\n hydrate(client, { queries: newQueries }, optionsRef.current)\n }\n if (existingQueries.length > 0) {\n return existingQueries\n }\n }\n return undefined\n }, [client, state])\n\n React.useEffect(() => {\n if (hydrationQueue) {\n hydrate(client, { queries: hydrationQueue }, optionsRef.current)\n }\n }, [client, hydrationQueue])\n\n return children as React.ReactElement\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,MAAa,qBAAqB,EAChC,UACA,UAAU,CAAC,GACX,OACA,kBAC4B;CAC5B,MAAM,SAASA,4BAAAA,eAAe,WAAW;CAEzC,MAAM,aAAaC,MAAM,OAAO,OAAO;CACvC,MAAM,gBAAgB;EACpB,WAAW,UAAU;CACvB,CAAC;CAiBD,MAAM,iBACJA,MAAM,cAAc;EAClB,IAAI,OAAO;GACT,IAAI,OAAO,UAAU,UACnB;GAGF,MAAM,aAAa,OAAO,cAAc;GAKxC,MAAM,UAAU,MAAM,WAAW,CAAC;GAElC,MAAM,aAAyC,CAAC;GAChD,MAAM,kBAA8C,CAAC;GACrD,KAAK,MAAM,mBAAmB,SAAS;IACrC,MAAM,gBAAgB,WAAW,IAAI,gBAAgB,SAAS;IAE9D,IAAI,CAAC,eACH,WAAW,KAAK,eAAe;SAW/B,IARE,gBAAgB,MAAM,gBACpB,cAAc,MAAM,iBACrB,gBAAgB,WACf,cAAc,MAAM,WAAW,aAC/B,cAAc,MAAM,gBAAgB,cACpC,gBAAgB,eACd,cAAc,MAAM,eAGxB,gBAAgB,KAAK,eAAe;GAG1C;GAEA,IAAI,WAAW,SAAS,GAItB,CAAA,GAAA,qBAAA,QAAA,CAAQ,QAAQ,EAAE,SAAS,WAAW,GAAG,WAAW,OAAO;GAE7D,IAAI,gBAAgB,SAAS,GAC3B,OAAO;EAEX;CAEF,GAAG,CAAC,QAAQ,KAAK,CAAC;CAEpB,MAAM,gBAAgB;EACpB,IAAI,gBACF,CAAA,GAAA,qBAAA,QAAA,CAAQ,QAAQ,EAAE,SAAS,eAAe,GAAG,WAAW,OAAO;CAEnE,GAAG,CAAC,QAAQ,cAAc,CAAC;CAE3B,OAAO;AACT"}
|
|
@@ -33,11 +33,11 @@ export interface HydrationBoundaryProps {
|
|
|
33
33
|
* update timestamp.
|
|
34
34
|
*
|
|
35
35
|
* Note: Only `queries` can be dehydrated with an `HydrationBoundary`.
|
|
36
|
-
*
|
|
36
|
+
* @param props - The dehydrated `state` to hydrate, the hydrate `options`, an optional custom
|
|
37
|
+
* `queryClient`, and the `children` to render.
|
|
37
38
|
* @returns The provided `children`, rendered unconditionally. New queries in `state` are hydrated into the
|
|
38
39
|
* cache during render; for queries already in the cache, only newer dehydrated data is hydrated, in an effect
|
|
39
40
|
* after commit.
|
|
40
|
-
*
|
|
41
41
|
* @example
|
|
42
42
|
* ```tsx
|
|
43
43
|
* import { HydrationBoundary } from '@tanstack/react-query'
|
|
@@ -46,7 +46,6 @@ export interface HydrationBoundaryProps {
|
|
|
46
46
|
* return <HydrationBoundary state={dehydratedState}>...</HydrationBoundary>
|
|
47
47
|
* }
|
|
48
48
|
* ```
|
|
49
|
-
*
|
|
50
49
|
* @example
|
|
51
50
|
* Server-side prefetch handed off to the client via `dehydrate`:
|
|
52
51
|
* ```tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HydrationBoundary.d.cts","names":[],"sources":["../../src/HydrationBoundary.tsx"],"mappings":";;;;;;iBAeiB;;;;EAIf,OAAO;;;;EAIP,UAAU,UAAU;IAClB,iBAAiB,UACf,QAAQ;;;;;;;;EAUZ,WAAW,MAAM;;;;EAIjB,cAAc
|
|
1
|
+
{"version":3,"file":"HydrationBoundary.d.cts","names":[],"sources":["../../src/HydrationBoundary.tsx"],"mappings":";;;;;;iBAeiB;;;;EAIf,OAAO;;;;EAIP,UAAU,UAAU;IAClB,iBAAiB,UACf,QAAQ;;;;;;;;EAUZ,WAAW,MAAM;;;;EAIjB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA6CH,sBAAqB,UAAA,SAAA,OAAA,eAK/B,2BA+EkB,MAAM"}
|
|
@@ -33,11 +33,11 @@ export interface HydrationBoundaryProps {
|
|
|
33
33
|
* update timestamp.
|
|
34
34
|
*
|
|
35
35
|
* Note: Only `queries` can be dehydrated with an `HydrationBoundary`.
|
|
36
|
-
*
|
|
36
|
+
* @param props - The dehydrated `state` to hydrate, the hydrate `options`, an optional custom
|
|
37
|
+
* `queryClient`, and the `children` to render.
|
|
37
38
|
* @returns The provided `children`, rendered unconditionally. New queries in `state` are hydrated into the
|
|
38
39
|
* cache during render; for queries already in the cache, only newer dehydrated data is hydrated, in an effect
|
|
39
40
|
* after commit.
|
|
40
|
-
*
|
|
41
41
|
* @example
|
|
42
42
|
* ```tsx
|
|
43
43
|
* import { HydrationBoundary } from '@tanstack/react-query'
|
|
@@ -46,7 +46,6 @@ export interface HydrationBoundaryProps {
|
|
|
46
46
|
* return <HydrationBoundary state={dehydratedState}>...</HydrationBoundary>
|
|
47
47
|
* }
|
|
48
48
|
* ```
|
|
49
|
-
*
|
|
50
49
|
* @example
|
|
51
50
|
* Server-side prefetch handed off to the client via `dehydrate`:
|
|
52
51
|
* ```tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HydrationBoundary.d.ts","names":[],"sources":["../../src/HydrationBoundary.tsx"],"mappings":";;;;;;iBAeiB;;;;EAIf,OAAO;;;;EAIP,UAAU,UAAU;IAClB,iBAAiB,UACf,QAAQ;;;;;;;;EAUZ,WAAW,MAAM;;;;EAIjB,cAAc
|
|
1
|
+
{"version":3,"file":"HydrationBoundary.d.ts","names":[],"sources":["../../src/HydrationBoundary.tsx"],"mappings":";;;;;;iBAeiB;;;;EAIf,OAAO;;;;EAIP,UAAU,UAAU;IAClB,iBAAiB,UACf,QAAQ;;;;;;;;EAUZ,WAAW,MAAM;;;;EAIjB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA6CH,sBAAqB,UAAA,SAAA,OAAA,eAK/B,2BA+EkB,MAAM"}
|
|
@@ -9,11 +9,11 @@ import { hydrate } from "@tanstack/query-core";
|
|
|
9
9
|
* update timestamp.
|
|
10
10
|
*
|
|
11
11
|
* Note: Only `queries` can be dehydrated with an `HydrationBoundary`.
|
|
12
|
-
*
|
|
12
|
+
* @param props - The dehydrated `state` to hydrate, the hydrate `options`, an optional custom
|
|
13
|
+
* `queryClient`, and the `children` to render.
|
|
13
14
|
* @returns The provided `children`, rendered unconditionally. New queries in `state` are hydrated into the
|
|
14
15
|
* cache during render; for queries already in the cache, only newer dehydrated data is hydrated, in an effect
|
|
15
16
|
* after commit.
|
|
16
|
-
*
|
|
17
17
|
* @example
|
|
18
18
|
* ```tsx
|
|
19
19
|
* import { HydrationBoundary } from '@tanstack/react-query'
|
|
@@ -22,7 +22,6 @@ import { hydrate } from "@tanstack/query-core";
|
|
|
22
22
|
* return <HydrationBoundary state={dehydratedState}>...</HydrationBoundary>
|
|
23
23
|
* }
|
|
24
24
|
* ```
|
|
25
|
-
*
|
|
26
25
|
* @example
|
|
27
26
|
* Server-side prefetch handed off to the client via `dehydrate`:
|
|
28
27
|
* ```tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HydrationBoundary.js","names":[],"sources":["../../src/HydrationBoundary.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport { hydrate } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\nimport type {\n DehydratedState,\n HydrateOptions,\n OmitKeyof,\n QueryClient,\n} from '@tanstack/query-core'\n\n/**\n * The props accepted by `HydrationBoundary`.\n */\nexport interface HydrationBoundaryProps {\n /**\n * The state to hydrate.\n */\n state: DehydratedState | null | undefined\n /**\n * Optional. Note: unlike `hydrate`, `mutations` cannot be set here.\n */\n options?: OmitKeyof<HydrateOptions, 'defaultOptions'> & {\n defaultOptions?: OmitKeyof<\n Exclude<HydrateOptions['defaultOptions'], undefined>,\n 'mutations'\n >\n }\n /**\n * The components to render — always rendered unconditionally, not gated on hydration. New queries are\n * hydrated into the cache during render; for queries that already exist in the cache, only newer dehydrated\n * data is hydrated, and that happens in an effect after commit, so `children` may render briefly before it\n * lands.\n */\n children?: React.ReactNode\n /**\n * Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used.\n */\n queryClient?: QueryClient\n}\n\n/**\n * `HydrationBoundary` adds a previously dehydrated state into the `queryClient` that would be returned by\n * `useQueryClient()`. If the client already contains data, the new queries will be intelligently merged based on\n * update timestamp.\n *\n * Note: Only `queries` can be dehydrated with an `HydrationBoundary`.\n
|
|
1
|
+
{"version":3,"file":"HydrationBoundary.js","names":[],"sources":["../../src/HydrationBoundary.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport { hydrate } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\nimport type {\n DehydratedState,\n HydrateOptions,\n OmitKeyof,\n QueryClient,\n} from '@tanstack/query-core'\n\n/**\n * The props accepted by `HydrationBoundary`.\n */\nexport interface HydrationBoundaryProps {\n /**\n * The state to hydrate.\n */\n state: DehydratedState | null | undefined\n /**\n * Optional. Note: unlike `hydrate`, `mutations` cannot be set here.\n */\n options?: OmitKeyof<HydrateOptions, 'defaultOptions'> & {\n defaultOptions?: OmitKeyof<\n Exclude<HydrateOptions['defaultOptions'], undefined>,\n 'mutations'\n >\n }\n /**\n * The components to render — always rendered unconditionally, not gated on hydration. New queries are\n * hydrated into the cache during render; for queries that already exist in the cache, only newer dehydrated\n * data is hydrated, and that happens in an effect after commit, so `children` may render briefly before it\n * lands.\n */\n children?: React.ReactNode\n /**\n * Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used.\n */\n queryClient?: QueryClient\n}\n\n/**\n * `HydrationBoundary` adds a previously dehydrated state into the `queryClient` that would be returned by\n * `useQueryClient()`. If the client already contains data, the new queries will be intelligently merged based on\n * update timestamp.\n *\n * Note: Only `queries` can be dehydrated with an `HydrationBoundary`.\n * @param props - The dehydrated `state` to hydrate, the hydrate `options`, an optional custom\n * `queryClient`, and the `children` to render.\n * @returns The provided `children`, rendered unconditionally. New queries in `state` are hydrated into the\n * cache during render; for queries already in the cache, only newer dehydrated data is hydrated, in an effect\n * after commit.\n * @example\n * ```tsx\n * import { HydrationBoundary } from '@tanstack/react-query'\n *\n * function App() {\n * return <HydrationBoundary state={dehydratedState}>...</HydrationBoundary>\n * }\n * ```\n * @example\n * Server-side prefetch handed off to the client via `dehydrate`:\n * ```tsx\n * import { HydrationBoundary, dehydrate, noop } from '@tanstack/react-query'\n *\n * async function ServerComponent() {\n * const queryClient = getQueryClient()\n *\n * await queryClient\n * .query({\n * queryKey: ['posts'],\n * queryFn: fetchPosts,\n * })\n * .catch(noop)\n *\n * return (\n * <HydrationBoundary state={dehydrate(queryClient)}>\n * <Posts />\n * </HydrationBoundary>\n * )\n * }\n * ```\n */\nexport const HydrationBoundary = ({\n children,\n options = {},\n state,\n queryClient,\n}: HydrationBoundaryProps) => {\n const client = useQueryClient(queryClient)\n\n const optionsRef = React.useRef(options)\n React.useEffect(() => {\n optionsRef.current = options\n })\n\n // This useMemo is for performance reasons only, everything inside it must\n // be safe to run in every render and code here should be read as \"in render\".\n //\n // This code needs to happen during the render phase, because after initial\n // SSR, hydration needs to happen _before_ children render. Also, if hydrating\n // during a transition, we want to hydrate as much as is safe in render so\n // we can prerender as much as possible.\n //\n // For any queries that already exist in the cache, we want to hold back on\n // hydrating until _after_ the render phase. The reason for this is that during\n // transitions, we don't want the existing queries and observers to update to\n // the new data on the current page, only _after_ the transition is committed.\n // If the transition is aborted, we will have hydrated any _new_ queries, but\n // we throw away the fresh data for any existing ones to avoid unexpectedly\n // updating the UI.\n const hydrationQueue: DehydratedState['queries'] | undefined =\n React.useMemo(() => {\n if (state) {\n if (typeof state !== 'object') {\n return\n }\n\n const queryCache = client.getQueryCache()\n // State is supplied from the outside and we might as well fail\n // gracefully if it has the wrong shape, so while we type `queries`\n // as required, we still provide a fallback.\n // oxlint-disable-next-line typescript/no-unnecessary-condition\n const queries = state.queries || []\n\n const newQueries: DehydratedState['queries'] = []\n const existingQueries: DehydratedState['queries'] = []\n for (const dehydratedQuery of queries) {\n const existingQuery = queryCache.get(dehydratedQuery.queryHash)\n\n if (!existingQuery) {\n newQueries.push(dehydratedQuery)\n } else {\n const hydrationIsNewer =\n dehydratedQuery.state.dataUpdatedAt >\n existingQuery.state.dataUpdatedAt ||\n (dehydratedQuery.promise &&\n existingQuery.state.status !== 'pending' &&\n existingQuery.state.fetchStatus !== 'fetching' &&\n dehydratedQuery.dehydratedAt >\n existingQuery.state.dataUpdatedAt)\n\n if (hydrationIsNewer) {\n existingQueries.push(dehydratedQuery)\n }\n }\n }\n\n if (newQueries.length > 0) {\n // It's actually fine to call this with queries/state that already exists\n // in the cache, or is older. hydrate() is idempotent for queries.\n // oxlint-disable-next-line react-hooks-js/refs\n hydrate(client, { queries: newQueries }, optionsRef.current)\n }\n if (existingQueries.length > 0) {\n return existingQueries\n }\n }\n return undefined\n }, [client, state])\n\n React.useEffect(() => {\n if (hydrationQueue) {\n hydrate(client, { queries: hydrationQueue }, optionsRef.current)\n }\n }, [client, hydrationQueue])\n\n return children as React.ReactElement\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,MAAa,qBAAqB,EAChC,UACA,UAAU,CAAC,GACX,OACA,kBAC4B;CAC5B,MAAM,SAAS,eAAe,WAAW;CAEzC,MAAM,aAAa,MAAM,OAAO,OAAO;CACvC,MAAM,gBAAgB;EACpB,WAAW,UAAU;CACvB,CAAC;CAiBD,MAAM,iBACJ,MAAM,cAAc;EAClB,IAAI,OAAO;GACT,IAAI,OAAO,UAAU,UACnB;GAGF,MAAM,aAAa,OAAO,cAAc;GAKxC,MAAM,UAAU,MAAM,WAAW,CAAC;GAElC,MAAM,aAAyC,CAAC;GAChD,MAAM,kBAA8C,CAAC;GACrD,KAAK,MAAM,mBAAmB,SAAS;IACrC,MAAM,gBAAgB,WAAW,IAAI,gBAAgB,SAAS;IAE9D,IAAI,CAAC,eACH,WAAW,KAAK,eAAe;SAW/B,IARE,gBAAgB,MAAM,gBACpB,cAAc,MAAM,iBACrB,gBAAgB,WACf,cAAc,MAAM,WAAW,aAC/B,cAAc,MAAM,gBAAgB,cACpC,gBAAgB,eACd,cAAc,MAAM,eAGxB,gBAAgB,KAAK,eAAe;GAG1C;GAEA,IAAI,WAAW,SAAS,GAItB,QAAQ,QAAQ,EAAE,SAAS,WAAW,GAAG,WAAW,OAAO;GAE7D,IAAI,gBAAgB,SAAS,GAC3B,OAAO;EAEX;CAEF,GAAG,CAAC,QAAQ,KAAK,CAAC;CAEpB,MAAM,gBAAgB;EACpB,IAAI,gBACF,QAAQ,QAAQ,EAAE,SAAS,eAAe,GAAG,WAAW,OAAO;CAEnE,GAAG,CAAC,QAAQ,cAAc,CAAC;CAE3B,OAAO;AACT"}
|
|
@@ -9,7 +9,6 @@ const IsRestoringContext = react.createContext(false);
|
|
|
9
9
|
* If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` hook alongside it to
|
|
10
10
|
* check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid
|
|
11
11
|
* race conditions between the restore and mounting queries.
|
|
12
|
-
*
|
|
13
12
|
* @returns `true` while a persisted client is being restored, `false` otherwise.
|
|
14
13
|
*/
|
|
15
14
|
const useIsRestoring = () => react.useContext(IsRestoringContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IsRestoringProvider.cjs","names":["React"],"sources":["../../src/IsRestoringProvider.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nconst IsRestoringContext = React.createContext(false)\n\n/**\n * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` hook alongside it to\n * check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid\n * race conditions between the restore and mounting queries.\n
|
|
1
|
+
{"version":3,"file":"IsRestoringProvider.cjs","names":["React"],"sources":["../../src/IsRestoringProvider.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nconst IsRestoringContext = React.createContext(false)\n\n/**\n * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` hook alongside it to\n * check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid\n * race conditions between the restore and mounting queries.\n * @returns `true` while a persisted client is being restored, `false` otherwise.\n */\nexport const useIsRestoring = () => React.useContext(IsRestoringContext)\n\n/**\n * The Provider that `PersistQueryClientProvider` uses to signal whether a persisted client is currently\n * being restored, read by `useIsRestoring`.\n */\nexport const IsRestoringProvider = IsRestoringContext.Provider\n"],"mappings":";;;;;;AAGA,MAAM,qBAAqBA,MAAM,cAAc,KAAK;;;;;;;AAQpD,MAAa,uBAAuBA,MAAM,WAAW,kBAAkB;;;;;AAMvE,MAAa,sBAAsB,mBAAmB"}
|
|
@@ -4,7 +4,6 @@ import * as React from "react";
|
|
|
4
4
|
* If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` hook alongside it to
|
|
5
5
|
* check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid
|
|
6
6
|
* race conditions between the restore and mounting queries.
|
|
7
|
-
*
|
|
8
7
|
* @returns `true` while a persisted client is being restored, `false` otherwise.
|
|
9
8
|
*/
|
|
10
9
|
export declare const useIsRestoring: () => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IsRestoringProvider.d.cts","names":[],"sources":["../../src/IsRestoringProvider.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"IsRestoringProvider.d.cts","names":[],"sources":["../../src/IsRestoringProvider.ts"],"mappings":";;;;;;;;qBAWa;;;;;qBAMA,qBAAmB,MAAA"}
|
|
@@ -4,7 +4,6 @@ import * as React from "react";
|
|
|
4
4
|
* If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` hook alongside it to
|
|
5
5
|
* check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid
|
|
6
6
|
* race conditions between the restore and mounting queries.
|
|
7
|
-
*
|
|
8
7
|
* @returns `true` while a persisted client is being restored, `false` otherwise.
|
|
9
8
|
*/
|
|
10
9
|
export declare const useIsRestoring: () => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IsRestoringProvider.d.ts","names":[],"sources":["../../src/IsRestoringProvider.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"IsRestoringProvider.d.ts","names":[],"sources":["../../src/IsRestoringProvider.ts"],"mappings":";;;;;;;;qBAWa;;;;;qBAMA,qBAAmB,MAAA"}
|
|
@@ -6,7 +6,6 @@ const IsRestoringContext = React.createContext(false);
|
|
|
6
6
|
* If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` hook alongside it to
|
|
7
7
|
* check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid
|
|
8
8
|
* race conditions between the restore and mounting queries.
|
|
9
|
-
*
|
|
10
9
|
* @returns `true` while a persisted client is being restored, `false` otherwise.
|
|
11
10
|
*/
|
|
12
11
|
const useIsRestoring = () => React.useContext(IsRestoringContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IsRestoringProvider.js","names":[],"sources":["../../src/IsRestoringProvider.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nconst IsRestoringContext = React.createContext(false)\n\n/**\n * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` hook alongside it to\n * check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid\n * race conditions between the restore and mounting queries.\n
|
|
1
|
+
{"version":3,"file":"IsRestoringProvider.js","names":[],"sources":["../../src/IsRestoringProvider.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nconst IsRestoringContext = React.createContext(false)\n\n/**\n * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` hook alongside it to\n * check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid\n * race conditions between the restore and mounting queries.\n * @returns `true` while a persisted client is being restored, `false` otherwise.\n */\nexport const useIsRestoring = () => React.useContext(IsRestoringContext)\n\n/**\n * The Provider that `PersistQueryClientProvider` uses to signal whether a persisted client is currently\n * being restored, read by `useIsRestoring`.\n */\nexport const IsRestoringProvider = IsRestoringContext.Provider\n"],"mappings":";;;AAGA,MAAM,qBAAqB,MAAM,cAAc,KAAK;;;;;;;AAQpD,MAAa,uBAAuB,MAAM,WAAW,kBAAkB;;;;;AAMvE,MAAa,sBAAsB,mBAAmB"}
|
|
@@ -11,11 +11,11 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
11
11
|
const QueryClientContext = react.createContext(void 0);
|
|
12
12
|
/**
|
|
13
13
|
* The `useQueryClient` hook returns the current `QueryClient` instance.
|
|
14
|
-
*
|
|
15
14
|
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
16
15
|
* be used.
|
|
17
16
|
* @returns The current `QueryClient` instance.
|
|
18
|
-
* @throws If no `queryClient` argument is passed and no `QueryClientProvider` is found in the
|
|
17
|
+
* @throws {Error} If no `queryClient` argument is passed and no `QueryClientProvider` is found in the
|
|
18
|
+
* component tree.
|
|
19
19
|
*/
|
|
20
20
|
const useQueryClient = (queryClient) => {
|
|
21
21
|
const client = react.useContext(QueryClientContext);
|
|
@@ -28,9 +28,8 @@ const useQueryClient = (queryClient) => {
|
|
|
28
28
|
* calls `client.mount()`/`client.unmount()` as this component mounts/unmounts, which subscribes the client to
|
|
29
29
|
* focus/online events (resuming any paused mutations and refetching as needed when the app regains focus or
|
|
30
30
|
* comes back online).
|
|
31
|
-
*
|
|
31
|
+
* @param props - The `client` to provide, and the `children` that get access to it.
|
|
32
32
|
* @returns The provided `children`, wrapped so they can read the `QueryClient` via `useQueryClient`.
|
|
33
|
-
*
|
|
34
33
|
* @example
|
|
35
34
|
* ```tsx
|
|
36
35
|
* import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryClientProvider.cjs","names":["React"],"sources":["../../src/QueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { QueryClient } from '@tanstack/query-core'\n\n/**\n * The context that `useQueryClient` reads from. `QueryClientProvider` is the normal way to set it.\n */\nexport const QueryClientContext = React.createContext<QueryClient | undefined>(\n undefined,\n)\n\n/**\n * The `useQueryClient` hook returns the current `QueryClient` instance.\n
|
|
1
|
+
{"version":3,"file":"QueryClientProvider.cjs","names":["React"],"sources":["../../src/QueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { QueryClient } from '@tanstack/query-core'\n\n/**\n * The context that `useQueryClient` reads from. `QueryClientProvider` is the normal way to set it.\n */\nexport const QueryClientContext = React.createContext<QueryClient | undefined>(\n undefined,\n)\n\n/**\n * The `useQueryClient` hook returns the current `QueryClient` instance.\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 `QueryClient` instance.\n * @throws {Error} If no `queryClient` argument is passed and no `QueryClientProvider` is found in the\n * component tree.\n */\nexport const useQueryClient = (queryClient?: QueryClient) => {\n const client = React.useContext(QueryClientContext)\n\n if (queryClient) {\n return queryClient\n }\n\n if (!client) {\n throw new Error('No QueryClient set, use QueryClientProvider to set one')\n }\n\n return client\n}\n\n/**\n * The props accepted by `QueryClientProvider`.\n */\nexport type QueryClientProviderProps = {\n /**\n * **Required**\n *\n * The `QueryClient` instance to provide.\n */\n client: QueryClient\n /**\n * The components that get access to the provided `QueryClient`.\n */\n children?: React.ReactNode\n}\n\n/**\n * Use the `QueryClientProvider` component to connect and provide a `QueryClient` to your application. Also\n * calls `client.mount()`/`client.unmount()` as this component mounts/unmounts, which subscribes the client to\n * focus/online events (resuming any paused mutations and refetching as needed when the app regains focus or\n * comes back online).\n * @param props - The `client` to provide, and the `children` that get access to it.\n * @returns The provided `children`, wrapped so they can read the `QueryClient` via `useQueryClient`.\n * @example\n * ```tsx\n * import { QueryClient, QueryClientProvider } from '@tanstack/react-query'\n *\n * const queryClient = new QueryClient()\n *\n * function App() {\n * return <QueryClientProvider client={queryClient}>...</QueryClientProvider>\n * }\n * ```\n */\nexport const QueryClientProvider = ({\n client,\n children,\n}: QueryClientProviderProps): React.JSX.Element => {\n React.useEffect(() => {\n client.mount()\n return () => {\n client.unmount()\n }\n }, [client])\n\n return (\n <QueryClientContext.Provider value={client}>\n {children}\n </QueryClientContext.Provider>\n )\n}\n"],"mappings":";;;;;;;;;;AAQA,MAAa,qBAAqBA,MAAM,cACtC,KAAA,CACF;;;;;;;;;AAUA,MAAa,kBAAkB,gBAA8B;CAC3D,MAAM,SAASA,MAAM,WAAW,kBAAkB;CAElD,IAAI,aACF,OAAO;CAGT,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,wDAAwD;CAG1E,OAAO;AACT;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,uBAAuB,EAClC,QACA,eACiD;CACjD,MAAM,gBAAgB;EACpB,OAAO,MAAM;EACb,aAAa;GACX,OAAO,QAAQ;EACjB;CACF,GAAG,CAAC,MAAM,CAAC;CAEX,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,mBAAmB,UAApB;EAA6B,OAAO;EACjC;CAC0B,CAAA;AAEjC"}
|
|
@@ -7,11 +7,11 @@ import { QueryClient } from "@tanstack/query-core";
|
|
|
7
7
|
export declare const QueryClientContext: React.Context<QueryClient | undefined>;
|
|
8
8
|
/**
|
|
9
9
|
* The `useQueryClient` hook returns the current `QueryClient` instance.
|
|
10
|
-
*
|
|
11
10
|
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
12
11
|
* be used.
|
|
13
12
|
* @returns The current `QueryClient` instance.
|
|
14
|
-
* @throws If no `queryClient` argument is passed and no `QueryClientProvider` is found in the
|
|
13
|
+
* @throws {Error} If no `queryClient` argument is passed and no `QueryClientProvider` is found in the
|
|
14
|
+
* component tree.
|
|
15
15
|
*/
|
|
16
16
|
export declare const useQueryClient: (queryClient?: QueryClient) => QueryClient;
|
|
17
17
|
/**
|
|
@@ -34,9 +34,8 @@ export type QueryClientProviderProps = {
|
|
|
34
34
|
* calls `client.mount()`/`client.unmount()` as this component mounts/unmounts, which subscribes the client to
|
|
35
35
|
* focus/online events (resuming any paused mutations and refetching as needed when the app regains focus or
|
|
36
36
|
* comes back online).
|
|
37
|
-
*
|
|
37
|
+
* @param props - The `client` to provide, and the `children` that get access to it.
|
|
38
38
|
* @returns The provided `children`, wrapped so they can read the `QueryClient` via `useQueryClient`.
|
|
39
|
-
*
|
|
40
39
|
* @example
|
|
41
40
|
* ```tsx
|
|
42
41
|
* import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryClientProvider.d.cts","names":[],"sources":["../../src/QueryClientProvider.tsx"],"mappings":";;;;;;qBAQa,oBAAkB,MAAA,QAAA;;;;;;;;;qBAYlB,iBAAkB,cAAc,gBAAW;;;;YAiB5C;;;;;;EAMV,QAAQ;;;;EAIR,WAAW,MAAM
|
|
1
|
+
{"version":3,"file":"QueryClientProvider.d.cts","names":[],"sources":["../../src/QueryClientProvider.tsx"],"mappings":";;;;;;qBAQa,oBAAkB,MAAA,QAAA;;;;;;;;;qBAYlB,iBAAkB,cAAc,gBAAW;;;;YAiB5C;;;;;;EAMV,QAAQ;;;;EAIR,WAAW,MAAM;;;;;;;;;;;;;;;;;;;;qBAqBN,wBAAuB,QAAA,YAGjC,6BAA2B,MAAM,IAAI"}
|
|
@@ -7,11 +7,11 @@ import { QueryClient } from "@tanstack/query-core";
|
|
|
7
7
|
export declare const QueryClientContext: React.Context<QueryClient | undefined>;
|
|
8
8
|
/**
|
|
9
9
|
* The `useQueryClient` hook returns the current `QueryClient` instance.
|
|
10
|
-
*
|
|
11
10
|
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
12
11
|
* be used.
|
|
13
12
|
* @returns The current `QueryClient` instance.
|
|
14
|
-
* @throws If no `queryClient` argument is passed and no `QueryClientProvider` is found in the
|
|
13
|
+
* @throws {Error} If no `queryClient` argument is passed and no `QueryClientProvider` is found in the
|
|
14
|
+
* component tree.
|
|
15
15
|
*/
|
|
16
16
|
export declare const useQueryClient: (queryClient?: QueryClient) => QueryClient;
|
|
17
17
|
/**
|
|
@@ -34,9 +34,8 @@ export type QueryClientProviderProps = {
|
|
|
34
34
|
* calls `client.mount()`/`client.unmount()` as this component mounts/unmounts, which subscribes the client to
|
|
35
35
|
* focus/online events (resuming any paused mutations and refetching as needed when the app regains focus or
|
|
36
36
|
* comes back online).
|
|
37
|
-
*
|
|
37
|
+
* @param props - The `client` to provide, and the `children` that get access to it.
|
|
38
38
|
* @returns The provided `children`, wrapped so they can read the `QueryClient` via `useQueryClient`.
|
|
39
|
-
*
|
|
40
39
|
* @example
|
|
41
40
|
* ```tsx
|
|
42
41
|
* import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryClientProvider.d.ts","names":[],"sources":["../../src/QueryClientProvider.tsx"],"mappings":";;;;;;qBAQa,oBAAkB,MAAA,QAAA;;;;;;;;;qBAYlB,iBAAkB,cAAc,gBAAW;;;;YAiB5C;;;;;;EAMV,QAAQ;;;;EAIR,WAAW,MAAM
|
|
1
|
+
{"version":3,"file":"QueryClientProvider.d.ts","names":[],"sources":["../../src/QueryClientProvider.tsx"],"mappings":";;;;;;qBAQa,oBAAkB,MAAA,QAAA;;;;;;;;;qBAYlB,iBAAkB,cAAc,gBAAW;;;;YAiB5C;;;;;;EAMV,QAAQ;;;;EAIR,WAAW,MAAM;;;;;;;;;;;;;;;;;;;;qBAqBN,wBAAuB,QAAA,YAGjC,6BAA2B,MAAM,IAAI"}
|
|
@@ -8,11 +8,11 @@ import { jsx } from "react/jsx-runtime";
|
|
|
8
8
|
const QueryClientContext = React.createContext(void 0);
|
|
9
9
|
/**
|
|
10
10
|
* The `useQueryClient` hook returns the current `QueryClient` instance.
|
|
11
|
-
*
|
|
12
11
|
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
|
|
13
12
|
* be used.
|
|
14
13
|
* @returns The current `QueryClient` instance.
|
|
15
|
-
* @throws If no `queryClient` argument is passed and no `QueryClientProvider` is found in the
|
|
14
|
+
* @throws {Error} If no `queryClient` argument is passed and no `QueryClientProvider` is found in the
|
|
15
|
+
* component tree.
|
|
16
16
|
*/
|
|
17
17
|
const useQueryClient = (queryClient) => {
|
|
18
18
|
const client = React.useContext(QueryClientContext);
|
|
@@ -25,9 +25,8 @@ const useQueryClient = (queryClient) => {
|
|
|
25
25
|
* calls `client.mount()`/`client.unmount()` as this component mounts/unmounts, which subscribes the client to
|
|
26
26
|
* focus/online events (resuming any paused mutations and refetching as needed when the app regains focus or
|
|
27
27
|
* comes back online).
|
|
28
|
-
*
|
|
28
|
+
* @param props - The `client` to provide, and the `children` that get access to it.
|
|
29
29
|
* @returns The provided `children`, wrapped so they can read the `QueryClient` via `useQueryClient`.
|
|
30
|
-
*
|
|
31
30
|
* @example
|
|
32
31
|
* ```tsx
|
|
33
32
|
* import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryClientProvider.js","names":[],"sources":["../../src/QueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { QueryClient } from '@tanstack/query-core'\n\n/**\n * The context that `useQueryClient` reads from. `QueryClientProvider` is the normal way to set it.\n */\nexport const QueryClientContext = React.createContext<QueryClient | undefined>(\n undefined,\n)\n\n/**\n * The `useQueryClient` hook returns the current `QueryClient` instance.\n
|
|
1
|
+
{"version":3,"file":"QueryClientProvider.js","names":[],"sources":["../../src/QueryClientProvider.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport type { QueryClient } from '@tanstack/query-core'\n\n/**\n * The context that `useQueryClient` reads from. `QueryClientProvider` is the normal way to set it.\n */\nexport const QueryClientContext = React.createContext<QueryClient | undefined>(\n undefined,\n)\n\n/**\n * The `useQueryClient` hook returns the current `QueryClient` instance.\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 `QueryClient` instance.\n * @throws {Error} If no `queryClient` argument is passed and no `QueryClientProvider` is found in the\n * component tree.\n */\nexport const useQueryClient = (queryClient?: QueryClient) => {\n const client = React.useContext(QueryClientContext)\n\n if (queryClient) {\n return queryClient\n }\n\n if (!client) {\n throw new Error('No QueryClient set, use QueryClientProvider to set one')\n }\n\n return client\n}\n\n/**\n * The props accepted by `QueryClientProvider`.\n */\nexport type QueryClientProviderProps = {\n /**\n * **Required**\n *\n * The `QueryClient` instance to provide.\n */\n client: QueryClient\n /**\n * The components that get access to the provided `QueryClient`.\n */\n children?: React.ReactNode\n}\n\n/**\n * Use the `QueryClientProvider` component to connect and provide a `QueryClient` to your application. Also\n * calls `client.mount()`/`client.unmount()` as this component mounts/unmounts, which subscribes the client to\n * focus/online events (resuming any paused mutations and refetching as needed when the app regains focus or\n * comes back online).\n * @param props - The `client` to provide, and the `children` that get access to it.\n * @returns The provided `children`, wrapped so they can read the `QueryClient` via `useQueryClient`.\n * @example\n * ```tsx\n * import { QueryClient, QueryClientProvider } from '@tanstack/react-query'\n *\n * const queryClient = new QueryClient()\n *\n * function App() {\n * return <QueryClientProvider client={queryClient}>...</QueryClientProvider>\n * }\n * ```\n */\nexport const QueryClientProvider = ({\n client,\n children,\n}: QueryClientProviderProps): React.JSX.Element => {\n React.useEffect(() => {\n client.mount()\n return () => {\n client.unmount()\n }\n }, [client])\n\n return (\n <QueryClientContext.Provider value={client}>\n {children}\n </QueryClientContext.Provider>\n )\n}\n"],"mappings":";;;;;;;AAQA,MAAa,qBAAqB,MAAM,cACtC,KAAA,CACF;;;;;;;;;AAUA,MAAa,kBAAkB,gBAA8B;CAC3D,MAAM,SAAS,MAAM,WAAW,kBAAkB;CAElD,IAAI,aACF,OAAO;CAGT,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,wDAAwD;CAG1E,OAAO;AACT;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,uBAAuB,EAClC,QACA,eACiD;CACjD,MAAM,gBAAgB;EACpB,OAAO,MAAM;EACb,aAAa;GACX,OAAO,QAAQ;EACjB;CACF,GAAG,CAAC,MAAM,CAAC;CAEX,OACE,oBAAC,mBAAmB,UAApB;EAA6B,OAAO;EACjC;CAC0B,CAAA;AAEjC"}
|
|
@@ -6,7 +6,9 @@ react = require_rolldown_runtime.__toESM(react, 1);
|
|
|
6
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
7
|
//#region src/QueryErrorResetBoundary.tsx
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Creates the value shared through the boundary's context, which tracks whether a reset was
|
|
10
|
+
* requested.
|
|
11
|
+
* @returns The `clearReset`, `isReset`, and `reset` functions of the boundary.
|
|
10
12
|
*/
|
|
11
13
|
function createValue() {
|
|
12
14
|
let isReset = false;
|
|
@@ -25,6 +27,7 @@ function createValue() {
|
|
|
25
27
|
},
|
|
26
28
|
/**
|
|
27
29
|
* Returns whether the boundary has been reset and not yet cleared.
|
|
30
|
+
* @returns `true` if the boundary has been reset and not yet cleared.
|
|
28
31
|
*/
|
|
29
32
|
isReset: () => {
|
|
30
33
|
return isReset;
|
|
@@ -35,9 +38,7 @@ const QueryErrorResetBoundaryContext = react.createContext(createValue());
|
|
|
35
38
|
/**
|
|
36
39
|
* This hook will reset any query errors within the closest `QueryErrorResetBoundary`. If there is no boundary
|
|
37
40
|
* defined it will reset them globally.
|
|
38
|
-
*
|
|
39
41
|
* @returns The boundary's {@link QueryErrorResetBoundaryValue}.
|
|
40
|
-
*
|
|
41
42
|
* @example
|
|
42
43
|
* ```tsx
|
|
43
44
|
* import { ErrorBoundary } from 'react-error-boundary'
|
|
@@ -67,10 +68,9 @@ const useQueryErrorResetBoundary = () => react.useContext(QueryErrorResetBoundar
|
|
|
67
68
|
* When using `suspense` or `throwOnError` in your queries, you need a way to let queries know that you want to
|
|
68
69
|
* try again when re-rendering after some error occurred. With the `QueryErrorResetBoundary` component you can
|
|
69
70
|
* reset any query errors within the boundaries of the component.
|
|
70
|
-
*
|
|
71
|
+
* @param props - The `children` to render.
|
|
71
72
|
* @returns The `children`, rendered as-is, or called with the boundary's {@link QueryErrorResetBoundaryValue}
|
|
72
73
|
* if `children` is a function.
|
|
73
|
-
*
|
|
74
74
|
* @example
|
|
75
75
|
* ```tsx
|
|
76
76
|
* import { ErrorBoundary } from 'react-error-boundary'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryErrorResetBoundary.cjs","names":["React"],"sources":["../../src/QueryErrorResetBoundary.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\n// CONTEXT\nexport type QueryErrorResetFunction = () => void\nexport type QueryErrorIsResetFunction = () => boolean\nexport type QueryErrorClearResetFunction = () => void\n\nexport interface QueryErrorResetBoundaryValue {\n clearReset: QueryErrorClearResetFunction\n isReset: QueryErrorIsResetFunction\n
|
|
1
|
+
{"version":3,"file":"QueryErrorResetBoundary.cjs","names":["React"],"sources":["../../src/QueryErrorResetBoundary.tsx"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\n// CONTEXT\n\n/**\n * Resets any query errors within the boundary, so queries know they can try again.\n */\nexport type QueryErrorResetFunction = () => void\n\n/**\n * Returns whether the boundary has been reset and not yet cleared.\n */\nexport type QueryErrorIsResetFunction = () => boolean\n\n/**\n * Clears the reset state, so queries know not to try again until the boundary is reset again.\n */\nexport type QueryErrorClearResetFunction = () => void\n\n/**\n * The value a `QueryErrorResetBoundary` shares through context, used to reset query errors within\n * it and to check whether a reset was requested.\n */\nexport interface QueryErrorResetBoundaryValue {\n /**\n * Clears the reset state, so queries know not to try again until the boundary is reset again.\n */\n clearReset: QueryErrorClearResetFunction\n /**\n * Returns whether the boundary has been reset and not yet cleared.\n */\n isReset: QueryErrorIsResetFunction\n /**\n * Resets any query errors within the boundary, so queries know they can try again.\n */\n reset: QueryErrorResetFunction\n}\n\n/**\n * Creates the value shared through the boundary's context, which tracks whether a reset was\n * requested.\n * @returns The `clearReset`, `isReset`, and `reset` functions of the boundary.\n */\nfunction createValue(): QueryErrorResetBoundaryValue {\n let isReset = false\n return {\n /**\n * Clears the reset state, so queries know not to try again until the boundary is reset again.\n */\n clearReset: () => {\n isReset = false\n },\n /**\n * Resets any query errors within the boundary, so queries know they can try again.\n */\n reset: () => {\n isReset = true\n },\n /**\n * Returns whether the boundary has been reset and not yet cleared.\n * @returns `true` if the boundary has been reset and not yet cleared.\n */\n isReset: () => {\n return isReset\n },\n }\n}\n\nconst QueryErrorResetBoundaryContext = React.createContext(createValue())\n\n// HOOK\n\n/**\n * This hook will reset any query errors within the closest `QueryErrorResetBoundary`. If there is no boundary\n * defined it will reset them globally.\n * @returns The boundary's {@link QueryErrorResetBoundaryValue}.\n * @example\n * ```tsx\n * import { ErrorBoundary } from 'react-error-boundary'\n * import { useQueryErrorResetBoundary } from '@tanstack/react-query'\n *\n * function App({ children }: { children: React.ReactNode }) {\n * const { reset } = useQueryErrorResetBoundary()\n *\n * return (\n * <ErrorBoundary\n * onReset={reset}\n * fallbackRender={({ resetErrorBoundary }) => (\n * <div>\n * There was an error!\n * <button onClick={() => resetErrorBoundary()}>Try again</button>\n * </div>\n * )}\n * >\n * {children}\n * </ErrorBoundary>\n * )\n * }\n * ```\n */\nexport const useQueryErrorResetBoundary = () =>\n React.useContext(QueryErrorResetBoundaryContext)\n\n// COMPONENT\n\n/**\n * A render-prop function usable as `children` on `QueryErrorResetBoundary`.\n * @param value - The boundary's {@link QueryErrorResetBoundaryValue}.\n * @returns The children to render.\n */\nexport type QueryErrorResetBoundaryFunction = (\n value: QueryErrorResetBoundaryValue,\n) => React.ReactNode\n\n/**\n * The props accepted by `QueryErrorResetBoundary`.\n */\nexport interface QueryErrorResetBoundaryProps {\n /**\n * Either a plain node, or a function that receives the boundary's {@link QueryErrorResetBoundaryValue} and\n * returns a node.\n */\n children: QueryErrorResetBoundaryFunction | React.ReactNode\n}\n\n/**\n * When using `suspense` or `throwOnError` in your queries, you need a way to let queries know that you want to\n * try again when re-rendering after some error occurred. With the `QueryErrorResetBoundary` component you can\n * reset any query errors within the boundaries of the component.\n * @param props - The `children` to render.\n * @returns The `children`, rendered as-is, or called with the boundary's {@link QueryErrorResetBoundaryValue}\n * if `children` is a function.\n * @example\n * ```tsx\n * import { ErrorBoundary } from 'react-error-boundary'\n * import { QueryErrorResetBoundary } from '@tanstack/react-query'\n *\n * function App() {\n * return (\n * <QueryErrorResetBoundary>\n * {({ reset }) => (\n * <ErrorBoundary\n * onReset={reset}\n * fallbackRender={({ resetErrorBoundary }) => (\n * <div>\n * There was an error!\n * <button onClick={() => resetErrorBoundary()}>Try again</button>\n * </div>\n * )}\n * >\n * <Page />\n * </ErrorBoundary>\n * )}\n * </QueryErrorResetBoundary>\n * )\n * }\n * ```\n */\nexport const QueryErrorResetBoundary = ({\n children,\n}: QueryErrorResetBoundaryProps) => {\n const [value] = React.useState(() => createValue())\n return (\n <QueryErrorResetBoundaryContext.Provider value={value}>\n {typeof children === 'function' ? children(value) : children}\n </QueryErrorResetBoundaryContext.Provider>\n )\n}\n"],"mappings":";;;;;;;;;;;;AA4CA,SAAS,cAA4C;CACnD,IAAI,UAAU;CACd,OAAO;;;;EAIL,kBAAkB;GAChB,UAAU;EACZ;;;;EAIA,aAAa;GACX,UAAU;EACZ;;;;;EAKA,eAAe;GACb,OAAO;EACT;CACF;AACF;AAEA,MAAM,iCAAiCA,MAAM,cAAc,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCxE,MAAa,mCACXA,MAAM,WAAW,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDjD,MAAa,2BAA2B,EACtC,eACkC;CAClC,MAAM,CAAC,SAASA,MAAM,eAAe,YAAY,CAAC;CAClD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,+BAA+B,UAAhC;EAAgD;EAC7C,UAAA,OAAO,aAAa,aAAa,SAAS,KAAK,IAAI;CACb,CAAA;AAE7C"}
|
|
@@ -1,19 +1,39 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
//#region src/QueryErrorResetBoundary.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Resets any query errors within the boundary, so queries know they can try again.
|
|
5
|
+
*/
|
|
3
6
|
export type QueryErrorResetFunction = () => void;
|
|
7
|
+
/**
|
|
8
|
+
* Returns whether the boundary has been reset and not yet cleared.
|
|
9
|
+
*/
|
|
4
10
|
export type QueryErrorIsResetFunction = () => boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Clears the reset state, so queries know not to try again until the boundary is reset again.
|
|
13
|
+
*/
|
|
5
14
|
export type QueryErrorClearResetFunction = () => void;
|
|
15
|
+
/**
|
|
16
|
+
* The value a `QueryErrorResetBoundary` shares through context, used to reset query errors within
|
|
17
|
+
* it and to check whether a reset was requested.
|
|
18
|
+
*/
|
|
6
19
|
export interface QueryErrorResetBoundaryValue {
|
|
20
|
+
/**
|
|
21
|
+
* Clears the reset state, so queries know not to try again until the boundary is reset again.
|
|
22
|
+
*/
|
|
7
23
|
clearReset: QueryErrorClearResetFunction;
|
|
24
|
+
/**
|
|
25
|
+
* Returns whether the boundary has been reset and not yet cleared.
|
|
26
|
+
*/
|
|
8
27
|
isReset: QueryErrorIsResetFunction;
|
|
28
|
+
/**
|
|
29
|
+
* Resets any query errors within the boundary, so queries know they can try again.
|
|
30
|
+
*/
|
|
9
31
|
reset: QueryErrorResetFunction;
|
|
10
32
|
}
|
|
11
33
|
/**
|
|
12
34
|
* This hook will reset any query errors within the closest `QueryErrorResetBoundary`. If there is no boundary
|
|
13
35
|
* defined it will reset them globally.
|
|
14
|
-
*
|
|
15
36
|
* @returns The boundary's {@link QueryErrorResetBoundaryValue}.
|
|
16
|
-
*
|
|
17
37
|
* @example
|
|
18
38
|
* ```tsx
|
|
19
39
|
* import { ErrorBoundary } from 'react-error-boundary'
|
|
@@ -41,7 +61,6 @@ export interface QueryErrorResetBoundaryValue {
|
|
|
41
61
|
export declare const useQueryErrorResetBoundary: () => QueryErrorResetBoundaryValue;
|
|
42
62
|
/**
|
|
43
63
|
* A render-prop function usable as `children` on `QueryErrorResetBoundary`.
|
|
44
|
-
*
|
|
45
64
|
* @param value - The boundary's {@link QueryErrorResetBoundaryValue}.
|
|
46
65
|
* @returns The children to render.
|
|
47
66
|
*/
|
|
@@ -60,10 +79,9 @@ export interface QueryErrorResetBoundaryProps {
|
|
|
60
79
|
* When using `suspense` or `throwOnError` in your queries, you need a way to let queries know that you want to
|
|
61
80
|
* try again when re-rendering after some error occurred. With the `QueryErrorResetBoundary` component you can
|
|
62
81
|
* reset any query errors within the boundaries of the component.
|
|
63
|
-
*
|
|
82
|
+
* @param props - The `children` to render.
|
|
64
83
|
* @returns The `children`, rendered as-is, or called with the boundary's {@link QueryErrorResetBoundaryValue}
|
|
65
84
|
* if `children` is a function.
|
|
66
|
-
*
|
|
67
85
|
* @example
|
|
68
86
|
* ```tsx
|
|
69
87
|
* import { ErrorBoundary } from 'react-error-boundary'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryErrorResetBoundary.d.cts","names":[],"sources":["../../src/QueryErrorResetBoundary.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"QueryErrorResetBoundary.d.cts","names":[],"sources":["../../src/QueryErrorResetBoundary.tsx"],"mappings":";;;;;YAQY;;;;YAKA;;;;YAKA;;;;;iBAMK;;;;EAIf,YAAY;;;;EAIZ,SAAS;;;;EAIT,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAiEI,kCAA0B;;;;;;YAU3B,mCACV,OAAO,iCACJ,MAAM;;;;iBAKM;;;;;EAKf,UAAU,kCAAkC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAoCvC,4BAA2B,YAErC,6DAA4B,IAAA"}
|
|
@@ -1,19 +1,39 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
//#region src/QueryErrorResetBoundary.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Resets any query errors within the boundary, so queries know they can try again.
|
|
5
|
+
*/
|
|
3
6
|
export type QueryErrorResetFunction = () => void;
|
|
7
|
+
/**
|
|
8
|
+
* Returns whether the boundary has been reset and not yet cleared.
|
|
9
|
+
*/
|
|
4
10
|
export type QueryErrorIsResetFunction = () => boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Clears the reset state, so queries know not to try again until the boundary is reset again.
|
|
13
|
+
*/
|
|
5
14
|
export type QueryErrorClearResetFunction = () => void;
|
|
15
|
+
/**
|
|
16
|
+
* The value a `QueryErrorResetBoundary` shares through context, used to reset query errors within
|
|
17
|
+
* it and to check whether a reset was requested.
|
|
18
|
+
*/
|
|
6
19
|
export interface QueryErrorResetBoundaryValue {
|
|
20
|
+
/**
|
|
21
|
+
* Clears the reset state, so queries know not to try again until the boundary is reset again.
|
|
22
|
+
*/
|
|
7
23
|
clearReset: QueryErrorClearResetFunction;
|
|
24
|
+
/**
|
|
25
|
+
* Returns whether the boundary has been reset and not yet cleared.
|
|
26
|
+
*/
|
|
8
27
|
isReset: QueryErrorIsResetFunction;
|
|
28
|
+
/**
|
|
29
|
+
* Resets any query errors within the boundary, so queries know they can try again.
|
|
30
|
+
*/
|
|
9
31
|
reset: QueryErrorResetFunction;
|
|
10
32
|
}
|
|
11
33
|
/**
|
|
12
34
|
* This hook will reset any query errors within the closest `QueryErrorResetBoundary`. If there is no boundary
|
|
13
35
|
* defined it will reset them globally.
|
|
14
|
-
*
|
|
15
36
|
* @returns The boundary's {@link QueryErrorResetBoundaryValue}.
|
|
16
|
-
*
|
|
17
37
|
* @example
|
|
18
38
|
* ```tsx
|
|
19
39
|
* import { ErrorBoundary } from 'react-error-boundary'
|
|
@@ -41,7 +61,6 @@ export interface QueryErrorResetBoundaryValue {
|
|
|
41
61
|
export declare const useQueryErrorResetBoundary: () => QueryErrorResetBoundaryValue;
|
|
42
62
|
/**
|
|
43
63
|
* A render-prop function usable as `children` on `QueryErrorResetBoundary`.
|
|
44
|
-
*
|
|
45
64
|
* @param value - The boundary's {@link QueryErrorResetBoundaryValue}.
|
|
46
65
|
* @returns The children to render.
|
|
47
66
|
*/
|
|
@@ -60,10 +79,9 @@ export interface QueryErrorResetBoundaryProps {
|
|
|
60
79
|
* When using `suspense` or `throwOnError` in your queries, you need a way to let queries know that you want to
|
|
61
80
|
* try again when re-rendering after some error occurred. With the `QueryErrorResetBoundary` component you can
|
|
62
81
|
* reset any query errors within the boundaries of the component.
|
|
63
|
-
*
|
|
82
|
+
* @param props - The `children` to render.
|
|
64
83
|
* @returns The `children`, rendered as-is, or called with the boundary's {@link QueryErrorResetBoundaryValue}
|
|
65
84
|
* if `children` is a function.
|
|
66
|
-
*
|
|
67
85
|
* @example
|
|
68
86
|
* ```tsx
|
|
69
87
|
* import { ErrorBoundary } from 'react-error-boundary'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryErrorResetBoundary.d.ts","names":[],"sources":["../../src/QueryErrorResetBoundary.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"QueryErrorResetBoundary.d.ts","names":[],"sources":["../../src/QueryErrorResetBoundary.tsx"],"mappings":";;;;;YAQY;;;;YAKA;;;;YAKA;;;;;iBAMK;;;;EAIf,YAAY;;;;EAIZ,SAAS;;;;EAIT,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAiEI,kCAA0B;;;;;;YAU3B,mCACV,OAAO,iCACJ,MAAM;;;;iBAKM;;;;;EAKf,UAAU,kCAAkC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAoCvC,4BAA2B,YAErC,6DAA4B,IAAA"}
|
|
@@ -3,7 +3,9 @@ import * as React from "react";
|
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
//#region src/QueryErrorResetBoundary.tsx
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Creates the value shared through the boundary's context, which tracks whether a reset was
|
|
7
|
+
* requested.
|
|
8
|
+
* @returns The `clearReset`, `isReset`, and `reset` functions of the boundary.
|
|
7
9
|
*/
|
|
8
10
|
function createValue() {
|
|
9
11
|
let isReset = false;
|
|
@@ -22,6 +24,7 @@ function createValue() {
|
|
|
22
24
|
},
|
|
23
25
|
/**
|
|
24
26
|
* Returns whether the boundary has been reset and not yet cleared.
|
|
27
|
+
* @returns `true` if the boundary has been reset and not yet cleared.
|
|
25
28
|
*/
|
|
26
29
|
isReset: () => {
|
|
27
30
|
return isReset;
|
|
@@ -32,9 +35,7 @@ const QueryErrorResetBoundaryContext = React.createContext(createValue());
|
|
|
32
35
|
/**
|
|
33
36
|
* This hook will reset any query errors within the closest `QueryErrorResetBoundary`. If there is no boundary
|
|
34
37
|
* defined it will reset them globally.
|
|
35
|
-
*
|
|
36
38
|
* @returns The boundary's {@link QueryErrorResetBoundaryValue}.
|
|
37
|
-
*
|
|
38
39
|
* @example
|
|
39
40
|
* ```tsx
|
|
40
41
|
* import { ErrorBoundary } from 'react-error-boundary'
|
|
@@ -64,10 +65,9 @@ const useQueryErrorResetBoundary = () => React.useContext(QueryErrorResetBoundar
|
|
|
64
65
|
* When using `suspense` or `throwOnError` in your queries, you need a way to let queries know that you want to
|
|
65
66
|
* try again when re-rendering after some error occurred. With the `QueryErrorResetBoundary` component you can
|
|
66
67
|
* reset any query errors within the boundaries of the component.
|
|
67
|
-
*
|
|
68
|
+
* @param props - The `children` to render.
|
|
68
69
|
* @returns The `children`, rendered as-is, or called with the boundary's {@link QueryErrorResetBoundaryValue}
|
|
69
70
|
* if `children` is a function.
|
|
70
|
-
*
|
|
71
71
|
* @example
|
|
72
72
|
* ```tsx
|
|
73
73
|
* import { ErrorBoundary } from 'react-error-boundary'
|