@tanstack/react-query 5.102.8 → 5.103.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (298) hide show
  1. package/build/legacy/HydrationBoundary.cjs +44 -1
  2. package/build/legacy/HydrationBoundary.cjs.map +1 -1
  3. package/build/legacy/HydrationBoundary.d.cts +61 -0
  4. package/build/legacy/HydrationBoundary.d.cts.map +1 -1
  5. package/build/legacy/HydrationBoundary.d.ts +61 -0
  6. package/build/legacy/HydrationBoundary.d.ts.map +1 -1
  7. package/build/legacy/HydrationBoundary.js +44 -1
  8. package/build/legacy/HydrationBoundary.js.map +1 -1
  9. package/build/legacy/IsRestoringProvider.cjs +11 -0
  10. package/build/legacy/IsRestoringProvider.cjs.map +1 -1
  11. package/build/legacy/IsRestoringProvider.d.cts +11 -0
  12. package/build/legacy/IsRestoringProvider.d.cts.map +1 -1
  13. package/build/legacy/IsRestoringProvider.d.ts +11 -0
  14. package/build/legacy/IsRestoringProvider.d.ts.map +1 -1
  15. package/build/legacy/IsRestoringProvider.js +11 -0
  16. package/build/legacy/IsRestoringProvider.js.map +1 -1
  17. package/build/legacy/QueryClientProvider.cjs +30 -0
  18. package/build/legacy/QueryClientProvider.cjs.map +1 -1
  19. package/build/legacy/QueryClientProvider.d.cts +41 -0
  20. package/build/legacy/QueryClientProvider.d.cts.map +1 -1
  21. package/build/legacy/QueryClientProvider.d.ts +41 -0
  22. package/build/legacy/QueryClientProvider.d.ts.map +1 -1
  23. package/build/legacy/QueryClientProvider.js +30 -0
  24. package/build/legacy/QueryClientProvider.js.map +1 -1
  25. package/build/legacy/QueryErrorResetBoundary.cjs +76 -0
  26. package/build/legacy/QueryErrorResetBoundary.cjs.map +1 -1
  27. package/build/legacy/QueryErrorResetBoundary.d.cts +77 -0
  28. package/build/legacy/QueryErrorResetBoundary.d.cts.map +1 -1
  29. package/build/legacy/QueryErrorResetBoundary.d.ts +77 -0
  30. package/build/legacy/QueryErrorResetBoundary.d.ts.map +1 -1
  31. package/build/legacy/QueryErrorResetBoundary.js +76 -0
  32. package/build/legacy/QueryErrorResetBoundary.js.map +1 -1
  33. package/build/legacy/infiniteQueryOptions.cjs.map +1 -1
  34. package/build/legacy/infiniteQueryOptions.d.cts +173 -0
  35. package/build/legacy/infiniteQueryOptions.d.cts.map +1 -1
  36. package/build/legacy/infiniteQueryOptions.d.ts +173 -0
  37. package/build/legacy/infiniteQueryOptions.d.ts.map +1 -1
  38. package/build/legacy/infiniteQueryOptions.js.map +1 -1
  39. package/build/legacy/mutationOptions.cjs.map +1 -1
  40. package/build/legacy/mutationOptions.d.cts +55 -0
  41. package/build/legacy/mutationOptions.d.cts.map +1 -1
  42. package/build/legacy/mutationOptions.d.ts +55 -0
  43. package/build/legacy/mutationOptions.d.ts.map +1 -1
  44. package/build/legacy/mutationOptions.js.map +1 -1
  45. package/build/legacy/queryOptions.cjs.map +1 -1
  46. package/build/legacy/queryOptions.d.cts +175 -0
  47. package/build/legacy/queryOptions.d.cts.map +1 -1
  48. package/build/legacy/queryOptions.d.ts +175 -0
  49. package/build/legacy/queryOptions.d.ts.map +1 -1
  50. package/build/legacy/queryOptions.js.map +1 -1
  51. package/build/legacy/types.cjs.map +1 -1
  52. package/build/legacy/types.d.cts +228 -2
  53. package/build/legacy/types.d.cts.map +1 -1
  54. package/build/legacy/types.d.ts +228 -2
  55. package/build/legacy/types.d.ts.map +1 -1
  56. package/build/legacy/types.js.map +1 -1
  57. package/build/legacy/useInfiniteQuery.cjs.map +1 -1
  58. package/build/legacy/useInfiniteQuery.d.cts +292 -0
  59. package/build/legacy/useInfiniteQuery.d.cts.map +1 -1
  60. package/build/legacy/useInfiniteQuery.d.ts +292 -0
  61. package/build/legacy/useInfiniteQuery.d.ts.map +1 -1
  62. package/build/legacy/useInfiniteQuery.js.map +1 -1
  63. package/build/legacy/useIsFetching.cjs +36 -0
  64. package/build/legacy/useIsFetching.cjs.map +1 -1
  65. package/build/legacy/useIsFetching.d.cts +36 -0
  66. package/build/legacy/useIsFetching.d.cts.map +1 -1
  67. package/build/legacy/useIsFetching.d.ts +36 -0
  68. package/build/legacy/useIsFetching.d.ts.map +1 -1
  69. package/build/legacy/useIsFetching.js +36 -0
  70. package/build/legacy/useIsFetching.js.map +1 -1
  71. package/build/legacy/useMutation.cjs +172 -0
  72. package/build/legacy/useMutation.cjs.map +1 -1
  73. package/build/legacy/useMutation.d.cts +172 -0
  74. package/build/legacy/useMutation.d.cts.map +1 -1
  75. package/build/legacy/useMutation.d.ts +172 -0
  76. package/build/legacy/useMutation.d.ts.map +1 -1
  77. package/build/legacy/useMutation.js +172 -0
  78. package/build/legacy/useMutation.js.map +1 -1
  79. package/build/legacy/useMutationState.cjs +94 -0
  80. package/build/legacy/useMutationState.cjs.map +1 -1
  81. package/build/legacy/useMutationState.d.cts +94 -0
  82. package/build/legacy/useMutationState.d.cts.map +1 -1
  83. package/build/legacy/useMutationState.d.ts +94 -0
  84. package/build/legacy/useMutationState.d.ts.map +1 -1
  85. package/build/legacy/useMutationState.js +94 -0
  86. package/build/legacy/useMutationState.js.map +1 -1
  87. package/build/legacy/usePrefetchInfiniteQuery.cjs +44 -0
  88. package/build/legacy/usePrefetchInfiniteQuery.cjs.map +1 -1
  89. package/build/legacy/usePrefetchInfiniteQuery.d.cts +44 -0
  90. package/build/legacy/usePrefetchInfiniteQuery.d.cts.map +1 -1
  91. package/build/legacy/usePrefetchInfiniteQuery.d.ts +44 -0
  92. package/build/legacy/usePrefetchInfiniteQuery.d.ts.map +1 -1
  93. package/build/legacy/usePrefetchInfiniteQuery.js +44 -0
  94. package/build/legacy/usePrefetchInfiniteQuery.js.map +1 -1
  95. package/build/legacy/usePrefetchQuery.cjs +35 -0
  96. package/build/legacy/usePrefetchQuery.cjs.map +1 -1
  97. package/build/legacy/usePrefetchQuery.d.cts +35 -0
  98. package/build/legacy/usePrefetchQuery.d.cts.map +1 -1
  99. package/build/legacy/usePrefetchQuery.d.ts +35 -0
  100. package/build/legacy/usePrefetchQuery.d.ts.map +1 -1
  101. package/build/legacy/usePrefetchQuery.js +35 -0
  102. package/build/legacy/usePrefetchQuery.js.map +1 -1
  103. package/build/legacy/useQueries.cjs +130 -0
  104. package/build/legacy/useQueries.cjs.map +1 -1
  105. package/build/legacy/useQueries.d.cts +165 -2
  106. package/build/legacy/useQueries.d.cts.map +1 -1
  107. package/build/legacy/useQueries.d.ts +165 -2
  108. package/build/legacy/useQueries.d.ts.map +1 -1
  109. package/build/legacy/useQueries.js +130 -0
  110. package/build/legacy/useQueries.js.map +1 -1
  111. package/build/legacy/useQuery.cjs.map +1 -1
  112. package/build/legacy/useQuery.d.cts +246 -0
  113. package/build/legacy/useQuery.d.cts.map +1 -1
  114. package/build/legacy/useQuery.d.ts +246 -0
  115. package/build/legacy/useQuery.d.ts.map +1 -1
  116. package/build/legacy/useQuery.js.map +1 -1
  117. package/build/legacy/useSuspenseInfiniteQuery.cjs +86 -0
  118. package/build/legacy/useSuspenseInfiniteQuery.cjs.map +1 -1
  119. package/build/legacy/useSuspenseInfiniteQuery.d.cts +86 -0
  120. package/build/legacy/useSuspenseInfiniteQuery.d.cts.map +1 -1
  121. package/build/legacy/useSuspenseInfiniteQuery.d.ts +86 -0
  122. package/build/legacy/useSuspenseInfiniteQuery.d.ts.map +1 -1
  123. package/build/legacy/useSuspenseInfiniteQuery.js +86 -0
  124. package/build/legacy/useSuspenseInfiniteQuery.js.map +1 -1
  125. package/build/legacy/useSuspenseQueries.cjs.map +1 -1
  126. package/build/legacy/useSuspenseQueries.d.cts +320 -2
  127. package/build/legacy/useSuspenseQueries.d.cts.map +1 -1
  128. package/build/legacy/useSuspenseQueries.d.ts +320 -2
  129. package/build/legacy/useSuspenseQueries.d.ts.map +1 -1
  130. package/build/legacy/useSuspenseQueries.js.map +1 -1
  131. package/build/legacy/useSuspenseQuery.cjs +67 -0
  132. package/build/legacy/useSuspenseQuery.cjs.map +1 -1
  133. package/build/legacy/useSuspenseQuery.d.cts +67 -0
  134. package/build/legacy/useSuspenseQuery.d.cts.map +1 -1
  135. package/build/legacy/useSuspenseQuery.d.ts +67 -0
  136. package/build/legacy/useSuspenseQuery.d.ts.map +1 -1
  137. package/build/legacy/useSuspenseQuery.js +67 -0
  138. package/build/legacy/useSuspenseQuery.js.map +1 -1
  139. package/build/modern/HydrationBoundary.cjs +44 -1
  140. package/build/modern/HydrationBoundary.cjs.map +1 -1
  141. package/build/modern/HydrationBoundary.d.cts +61 -0
  142. package/build/modern/HydrationBoundary.d.cts.map +1 -1
  143. package/build/modern/HydrationBoundary.d.ts +61 -0
  144. package/build/modern/HydrationBoundary.d.ts.map +1 -1
  145. package/build/modern/HydrationBoundary.js +44 -1
  146. package/build/modern/HydrationBoundary.js.map +1 -1
  147. package/build/modern/IsRestoringProvider.cjs +11 -0
  148. package/build/modern/IsRestoringProvider.cjs.map +1 -1
  149. package/build/modern/IsRestoringProvider.d.cts +11 -0
  150. package/build/modern/IsRestoringProvider.d.cts.map +1 -1
  151. package/build/modern/IsRestoringProvider.d.ts +11 -0
  152. package/build/modern/IsRestoringProvider.d.ts.map +1 -1
  153. package/build/modern/IsRestoringProvider.js +11 -0
  154. package/build/modern/IsRestoringProvider.js.map +1 -1
  155. package/build/modern/QueryClientProvider.cjs +30 -0
  156. package/build/modern/QueryClientProvider.cjs.map +1 -1
  157. package/build/modern/QueryClientProvider.d.cts +41 -0
  158. package/build/modern/QueryClientProvider.d.cts.map +1 -1
  159. package/build/modern/QueryClientProvider.d.ts +41 -0
  160. package/build/modern/QueryClientProvider.d.ts.map +1 -1
  161. package/build/modern/QueryClientProvider.js +30 -0
  162. package/build/modern/QueryClientProvider.js.map +1 -1
  163. package/build/modern/QueryErrorResetBoundary.cjs +76 -0
  164. package/build/modern/QueryErrorResetBoundary.cjs.map +1 -1
  165. package/build/modern/QueryErrorResetBoundary.d.cts +77 -0
  166. package/build/modern/QueryErrorResetBoundary.d.cts.map +1 -1
  167. package/build/modern/QueryErrorResetBoundary.d.ts +77 -0
  168. package/build/modern/QueryErrorResetBoundary.d.ts.map +1 -1
  169. package/build/modern/QueryErrorResetBoundary.js +76 -0
  170. package/build/modern/QueryErrorResetBoundary.js.map +1 -1
  171. package/build/modern/infiniteQueryOptions.cjs.map +1 -1
  172. package/build/modern/infiniteQueryOptions.d.cts +173 -0
  173. package/build/modern/infiniteQueryOptions.d.cts.map +1 -1
  174. package/build/modern/infiniteQueryOptions.d.ts +173 -0
  175. package/build/modern/infiniteQueryOptions.d.ts.map +1 -1
  176. package/build/modern/infiniteQueryOptions.js.map +1 -1
  177. package/build/modern/mutationOptions.cjs.map +1 -1
  178. package/build/modern/mutationOptions.d.cts +55 -0
  179. package/build/modern/mutationOptions.d.cts.map +1 -1
  180. package/build/modern/mutationOptions.d.ts +55 -0
  181. package/build/modern/mutationOptions.d.ts.map +1 -1
  182. package/build/modern/mutationOptions.js.map +1 -1
  183. package/build/modern/queryOptions.cjs.map +1 -1
  184. package/build/modern/queryOptions.d.cts +175 -0
  185. package/build/modern/queryOptions.d.cts.map +1 -1
  186. package/build/modern/queryOptions.d.ts +175 -0
  187. package/build/modern/queryOptions.d.ts.map +1 -1
  188. package/build/modern/queryOptions.js.map +1 -1
  189. package/build/modern/types.cjs.map +1 -1
  190. package/build/modern/types.d.cts +228 -2
  191. package/build/modern/types.d.cts.map +1 -1
  192. package/build/modern/types.d.ts +228 -2
  193. package/build/modern/types.d.ts.map +1 -1
  194. package/build/modern/types.js.map +1 -1
  195. package/build/modern/useInfiniteQuery.cjs.map +1 -1
  196. package/build/modern/useInfiniteQuery.d.cts +292 -0
  197. package/build/modern/useInfiniteQuery.d.cts.map +1 -1
  198. package/build/modern/useInfiniteQuery.d.ts +292 -0
  199. package/build/modern/useInfiniteQuery.d.ts.map +1 -1
  200. package/build/modern/useInfiniteQuery.js.map +1 -1
  201. package/build/modern/useIsFetching.cjs +36 -0
  202. package/build/modern/useIsFetching.cjs.map +1 -1
  203. package/build/modern/useIsFetching.d.cts +36 -0
  204. package/build/modern/useIsFetching.d.cts.map +1 -1
  205. package/build/modern/useIsFetching.d.ts +36 -0
  206. package/build/modern/useIsFetching.d.ts.map +1 -1
  207. package/build/modern/useIsFetching.js +36 -0
  208. package/build/modern/useIsFetching.js.map +1 -1
  209. package/build/modern/useMutation.cjs +172 -0
  210. package/build/modern/useMutation.cjs.map +1 -1
  211. package/build/modern/useMutation.d.cts +172 -0
  212. package/build/modern/useMutation.d.cts.map +1 -1
  213. package/build/modern/useMutation.d.ts +172 -0
  214. package/build/modern/useMutation.d.ts.map +1 -1
  215. package/build/modern/useMutation.js +172 -0
  216. package/build/modern/useMutation.js.map +1 -1
  217. package/build/modern/useMutationState.cjs +94 -0
  218. package/build/modern/useMutationState.cjs.map +1 -1
  219. package/build/modern/useMutationState.d.cts +94 -0
  220. package/build/modern/useMutationState.d.cts.map +1 -1
  221. package/build/modern/useMutationState.d.ts +94 -0
  222. package/build/modern/useMutationState.d.ts.map +1 -1
  223. package/build/modern/useMutationState.js +94 -0
  224. package/build/modern/useMutationState.js.map +1 -1
  225. package/build/modern/usePrefetchInfiniteQuery.cjs +44 -0
  226. package/build/modern/usePrefetchInfiniteQuery.cjs.map +1 -1
  227. package/build/modern/usePrefetchInfiniteQuery.d.cts +44 -0
  228. package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -1
  229. package/build/modern/usePrefetchInfiniteQuery.d.ts +44 -0
  230. package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -1
  231. package/build/modern/usePrefetchInfiniteQuery.js +44 -0
  232. package/build/modern/usePrefetchInfiniteQuery.js.map +1 -1
  233. package/build/modern/usePrefetchQuery.cjs +35 -0
  234. package/build/modern/usePrefetchQuery.cjs.map +1 -1
  235. package/build/modern/usePrefetchQuery.d.cts +35 -0
  236. package/build/modern/usePrefetchQuery.d.cts.map +1 -1
  237. package/build/modern/usePrefetchQuery.d.ts +35 -0
  238. package/build/modern/usePrefetchQuery.d.ts.map +1 -1
  239. package/build/modern/usePrefetchQuery.js +35 -0
  240. package/build/modern/usePrefetchQuery.js.map +1 -1
  241. package/build/modern/useQueries.cjs +130 -0
  242. package/build/modern/useQueries.cjs.map +1 -1
  243. package/build/modern/useQueries.d.cts +165 -2
  244. package/build/modern/useQueries.d.cts.map +1 -1
  245. package/build/modern/useQueries.d.ts +165 -2
  246. package/build/modern/useQueries.d.ts.map +1 -1
  247. package/build/modern/useQueries.js +130 -0
  248. package/build/modern/useQueries.js.map +1 -1
  249. package/build/modern/useQuery.cjs.map +1 -1
  250. package/build/modern/useQuery.d.cts +246 -0
  251. package/build/modern/useQuery.d.cts.map +1 -1
  252. package/build/modern/useQuery.d.ts +246 -0
  253. package/build/modern/useQuery.d.ts.map +1 -1
  254. package/build/modern/useQuery.js.map +1 -1
  255. package/build/modern/useSuspenseInfiniteQuery.cjs +86 -0
  256. package/build/modern/useSuspenseInfiniteQuery.cjs.map +1 -1
  257. package/build/modern/useSuspenseInfiniteQuery.d.cts +86 -0
  258. package/build/modern/useSuspenseInfiniteQuery.d.cts.map +1 -1
  259. package/build/modern/useSuspenseInfiniteQuery.d.ts +86 -0
  260. package/build/modern/useSuspenseInfiniteQuery.d.ts.map +1 -1
  261. package/build/modern/useSuspenseInfiniteQuery.js +86 -0
  262. package/build/modern/useSuspenseInfiniteQuery.js.map +1 -1
  263. package/build/modern/useSuspenseQueries.cjs.map +1 -1
  264. package/build/modern/useSuspenseQueries.d.cts +320 -2
  265. package/build/modern/useSuspenseQueries.d.cts.map +1 -1
  266. package/build/modern/useSuspenseQueries.d.ts +320 -2
  267. package/build/modern/useSuspenseQueries.d.ts.map +1 -1
  268. package/build/modern/useSuspenseQueries.js.map +1 -1
  269. package/build/modern/useSuspenseQuery.cjs +67 -0
  270. package/build/modern/useSuspenseQuery.cjs.map +1 -1
  271. package/build/modern/useSuspenseQuery.d.cts +67 -0
  272. package/build/modern/useSuspenseQuery.d.cts.map +1 -1
  273. package/build/modern/useSuspenseQuery.d.ts +67 -0
  274. package/build/modern/useSuspenseQuery.d.ts.map +1 -1
  275. package/build/modern/useSuspenseQuery.js +67 -0
  276. package/build/modern/useSuspenseQuery.js.map +1 -1
  277. package/build/query-codemods/eslint.config.js +7 -0
  278. package/build/query-codemods/root.eslint.config.js +45 -0
  279. package/package.json +11 -11
  280. package/src/HydrationBoundary.tsx +61 -1
  281. package/src/IsRestoringProvider.ts +12 -0
  282. package/src/QueryClientProvider.tsx +41 -0
  283. package/src/QueryErrorResetBoundary.tsx +89 -0
  284. package/src/infiniteQueryOptions.ts +173 -0
  285. package/src/mutationOptions.ts +55 -0
  286. package/src/queryOptions.ts +175 -0
  287. package/src/types.ts +228 -2
  288. package/src/useInfiniteQuery.ts +292 -0
  289. package/src/useIsFetching.ts +36 -0
  290. package/src/useMutation.ts +172 -0
  291. package/src/useMutationState.ts +94 -0
  292. package/src/usePrefetchInfiniteQuery.tsx +44 -0
  293. package/src/usePrefetchQuery.tsx +35 -0
  294. package/src/useQueries.ts +165 -2
  295. package/src/useQuery.ts +246 -0
  296. package/src/useSuspenseInfiniteQuery.ts +86 -0
  297. package/src/useSuspenseQueries.ts +320 -2
  298. package/src/useSuspenseQuery.ts +67 -0
@@ -1,14 +1,75 @@
1
1
  import * as React from "react";
2
2
  import { DehydratedState, HydrateOptions, OmitKeyof, QueryClient } from "@tanstack/query-core";
3
3
  //#region src/HydrationBoundary.d.ts
4
+ /**
5
+ * The props accepted by `HydrationBoundary`.
6
+ */
4
7
  interface HydrationBoundaryProps {
8
+ /**
9
+ * The state to hydrate.
10
+ */
5
11
  state: DehydratedState | null | undefined;
12
+ /**
13
+ * Optional. Note: unlike `hydrate`, `mutations` cannot be set here.
14
+ */
6
15
  options?: OmitKeyof<HydrateOptions, 'defaultOptions'> & {
7
16
  defaultOptions?: OmitKeyof<Exclude<HydrateOptions['defaultOptions'], undefined>, 'mutations'>;
8
17
  };
18
+ /**
19
+ * The components to render — always rendered unconditionally, not gated on hydration. New queries are
20
+ * hydrated into the cache during render; for queries that already exist in the cache, only newer dehydrated
21
+ * data is hydrated, and that happens in an effect after commit, so `children` may render briefly before it
22
+ * lands.
23
+ */
9
24
  children?: React.ReactNode;
25
+ /**
26
+ * Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used.
27
+ */
10
28
  queryClient?: QueryClient;
11
29
  }
30
+ /**
31
+ * `HydrationBoundary` adds a previously dehydrated state into the `queryClient` that would be returned by
32
+ * `useQueryClient()`. If the client already contains data, the new queries will be intelligently merged based on
33
+ * update timestamp.
34
+ *
35
+ * Note: Only `queries` can be dehydrated with an `HydrationBoundary`.
36
+ *
37
+ * @returns The provided `children`, rendered unconditionally. New queries in `state` are hydrated into the
38
+ * cache during render; for queries already in the cache, only newer dehydrated data is hydrated, in an effect
39
+ * after commit.
40
+ *
41
+ * @example
42
+ * ```tsx
43
+ * import { HydrationBoundary } from '@tanstack/react-query'
44
+ *
45
+ * function App() {
46
+ * return <HydrationBoundary state={dehydratedState}>...</HydrationBoundary>
47
+ * }
48
+ * ```
49
+ *
50
+ * @example
51
+ * Server-side prefetch handed off to the client via `dehydrate`:
52
+ * ```tsx
53
+ * import { HydrationBoundary, dehydrate, noop } from '@tanstack/react-query'
54
+ *
55
+ * async function ServerComponent() {
56
+ * const queryClient = getQueryClient()
57
+ *
58
+ * await queryClient
59
+ * .query({
60
+ * queryKey: ['posts'],
61
+ * queryFn: fetchPosts,
62
+ * })
63
+ * .catch(noop)
64
+ *
65
+ * return (
66
+ * <HydrationBoundary state={dehydrate(queryClient)}>
67
+ * <Posts />
68
+ * </HydrationBoundary>
69
+ * )
70
+ * }
71
+ * ```
72
+ */
12
73
  declare const HydrationBoundary: ({ children, options, state, queryClient }: HydrationBoundaryProps) => React.ReactElement;
13
74
  //#endregion
14
75
  export { HydrationBoundary, HydrationBoundaryProps };
@@ -1 +1 @@
1
- {"version":3,"file":"HydrationBoundary.d.ts","names":[],"sources":["../../src/HydrationBoundary.tsx"],"mappings":";;;UAYiB;EACf,OAAO;EACP,UAAU,UAAU;IAClB,iBAAiB,UACf,QAAQ;;EAIZ,WAAW,MAAM;EACjB,cAAc;;cAGH,sBAAqB,UAAA,SAAA,OAAA,eAK/B,2BAgFkB,MAAM"}
1
+ {"version":3,"file":"HydrationBoundary.d.ts","names":[],"sources":["../../src/HydrationBoundary.tsx"],"mappings":";;;;;;UAeiB;;;;EAIf,OAAO;;;;EAIP,UAAU,UAAU;IAClB,iBAAiB,UACf,QAAQ;;;;;;;;EAUZ,WAAW,MAAM;;;;EAIjB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8CH,sBAAqB,UAAA,SAAA,OAAA,eAK/B,2BA+EkB,MAAM"}
@@ -3,6 +3,49 @@ import { useQueryClient } from "./QueryClientProvider.js";
3
3
  import * as React from "react";
4
4
  import { hydrate } from "@tanstack/query-core";
5
5
  //#region src/HydrationBoundary.tsx
6
+ /**
7
+ * `HydrationBoundary` adds a previously dehydrated state into the `queryClient` that would be returned by
8
+ * `useQueryClient()`. If the client already contains data, the new queries will be intelligently merged based on
9
+ * update timestamp.
10
+ *
11
+ * Note: Only `queries` can be dehydrated with an `HydrationBoundary`.
12
+ *
13
+ * @returns The provided `children`, rendered unconditionally. New queries in `state` are hydrated into the
14
+ * cache during render; for queries already in the cache, only newer dehydrated data is hydrated, in an effect
15
+ * after commit.
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * import { HydrationBoundary } from '@tanstack/react-query'
20
+ *
21
+ * function App() {
22
+ * return <HydrationBoundary state={dehydratedState}>...</HydrationBoundary>
23
+ * }
24
+ * ```
25
+ *
26
+ * @example
27
+ * Server-side prefetch handed off to the client via `dehydrate`:
28
+ * ```tsx
29
+ * import { HydrationBoundary, dehydrate, noop } from '@tanstack/react-query'
30
+ *
31
+ * async function ServerComponent() {
32
+ * const queryClient = getQueryClient()
33
+ *
34
+ * await queryClient
35
+ * .query({
36
+ * queryKey: ['posts'],
37
+ * queryFn: fetchPosts,
38
+ * })
39
+ * .catch(noop)
40
+ *
41
+ * return (
42
+ * <HydrationBoundary state={dehydrate(queryClient)}>
43
+ * <Posts />
44
+ * </HydrationBoundary>
45
+ * )
46
+ * }
47
+ * ```
48
+ */
6
49
  const HydrationBoundary = ({ children, options = {}, state, queryClient }) => {
7
50
  const client = useQueryClient(queryClient);
8
51
  const optionsRef = React.useRef(options);
@@ -19,7 +62,7 @@ const HydrationBoundary = ({ children, options = {}, state, queryClient }) => {
19
62
  for (const dehydratedQuery of queries) {
20
63
  const existingQuery = queryCache.get(dehydratedQuery.queryHash);
21
64
  if (!existingQuery) newQueries.push(dehydratedQuery);
22
- else if (dehydratedQuery.state.dataUpdatedAt > existingQuery.state.dataUpdatedAt || dehydratedQuery.promise && existingQuery.state.status !== "pending" && existingQuery.state.fetchStatus !== "fetching" && dehydratedQuery.dehydratedAt !== void 0 && dehydratedQuery.dehydratedAt > existingQuery.state.dataUpdatedAt) existingQueries.push(dehydratedQuery);
65
+ else if (dehydratedQuery.state.dataUpdatedAt > existingQuery.state.dataUpdatedAt || dehydratedQuery.promise && existingQuery.state.status !== "pending" && existingQuery.state.fetchStatus !== "fetching" && dehydratedQuery.dehydratedAt > existingQuery.state.dataUpdatedAt) existingQueries.push(dehydratedQuery);
23
66
  }
24
67
  if (newQueries.length > 0) hydrate(client, { queries: newQueries }, optionsRef.current);
25
68
  if (existingQueries.length > 0) return existingQueries;
@@ -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\nexport interface HydrationBoundaryProps {\n state: DehydratedState | null | undefined\n options?: OmitKeyof<HydrateOptions, 'defaultOptions'> & {\n defaultOptions?: OmitKeyof<\n Exclude<HydrateOptions['defaultOptions'], undefined>,\n 'mutations'\n >\n }\n children?: React.ReactNode\n queryClient?: QueryClient\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 // eslint-disable-next-line @typescript-eslint/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 !== undefined &&\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 // eslint-disable-next-line react-hooks/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":";;;;;AAwBA,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;SAY/B,IATE,gBAAgB,MAAM,gBACpB,cAAc,MAAM,iBACrB,gBAAgB,WACf,cAAc,MAAM,WAAW,aAC/B,cAAc,MAAM,gBAAgB,cACpC,gBAAgB,iBAAiB,KAAA,KACjC,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"}
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 *\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 *\n * @example\n * ```tsx\n * import { HydrationBoundary } from '@tanstack/react-query'\n *\n * function App() {\n * return <HydrationBoundary state={dehydratedState}>...</HydrationBoundary>\n * }\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 // eslint-disable-next-line @typescript-eslint/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 // eslint-disable-next-line react-hooks/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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqFA,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"}
@@ -5,7 +5,18 @@ let react = require("react");
5
5
  react = require_rolldown_runtime.__toESM(react, 1);
6
6
  //#region src/IsRestoringProvider.ts
7
7
  const IsRestoringContext = react.createContext(false);
8
+ /**
9
+ * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` hook alongside it to
10
+ * check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid
11
+ * race conditions between the restore and mounting queries.
12
+ *
13
+ * @returns `true` while a persisted client is being restored, `false` otherwise.
14
+ */
8
15
  const useIsRestoring = () => react.useContext(IsRestoringContext);
16
+ /**
17
+ * The Provider that `PersistQueryClientProvider` uses to signal whether a persisted client is currently
18
+ * being restored, read by `useIsRestoring`.
19
+ */
9
20
  const IsRestoringProvider = IsRestoringContext.Provider;
10
21
  //#endregion
11
22
  exports.IsRestoringProvider = IsRestoringProvider;
@@ -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\nexport const useIsRestoring = () => React.useContext(IsRestoringContext)\nexport const IsRestoringProvider = IsRestoringContext.Provider\n"],"mappings":";;;;;;AAGA,MAAM,qBAAqBA,MAAM,cAAc,KAAK;AAEpD,MAAa,uBAAuBA,MAAM,WAAW,kBAAkB;AACvE,MAAa,sBAAsB,mBAAmB"}
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 *\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;;;;;;;;AASpD,MAAa,uBAAuBA,MAAM,WAAW,kBAAkB;;;;;AAMvE,MAAa,sBAAsB,mBAAmB"}
@@ -1,6 +1,17 @@
1
1
  import * as React from "react";
2
2
  //#region src/IsRestoringProvider.d.ts
3
+ /**
4
+ * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` hook alongside it to
5
+ * check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid
6
+ * race conditions between the restore and mounting queries.
7
+ *
8
+ * @returns `true` while a persisted client is being restored, `false` otherwise.
9
+ */
3
10
  declare const useIsRestoring: () => boolean;
11
+ /**
12
+ * The Provider that `PersistQueryClientProvider` uses to signal whether a persisted client is currently
13
+ * being restored, read by `useIsRestoring`.
14
+ */
4
15
  declare const IsRestoringProvider: React.Provider<boolean>;
5
16
  //#endregion
6
17
  export { IsRestoringProvider, useIsRestoring };
@@ -1 +1 @@
1
- {"version":3,"file":"IsRestoringProvider.d.cts","names":[],"sources":["../../src/IsRestoringProvider.ts"],"mappings":";;cAKa;cACA,qBAAmB,MAAA"}
1
+ {"version":3,"file":"IsRestoringProvider.d.cts","names":[],"sources":["../../src/IsRestoringProvider.ts"],"mappings":";;;;;;;;;cAYa;;;;;cAMA,qBAAmB,MAAA"}
@@ -1,6 +1,17 @@
1
1
  import * as React from "react";
2
2
  //#region src/IsRestoringProvider.d.ts
3
+ /**
4
+ * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` hook alongside it to
5
+ * check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid
6
+ * race conditions between the restore and mounting queries.
7
+ *
8
+ * @returns `true` while a persisted client is being restored, `false` otherwise.
9
+ */
3
10
  declare const useIsRestoring: () => boolean;
11
+ /**
12
+ * The Provider that `PersistQueryClientProvider` uses to signal whether a persisted client is currently
13
+ * being restored, read by `useIsRestoring`.
14
+ */
4
15
  declare const IsRestoringProvider: React.Provider<boolean>;
5
16
  //#endregion
6
17
  export { IsRestoringProvider, useIsRestoring };
@@ -1 +1 @@
1
- {"version":3,"file":"IsRestoringProvider.d.ts","names":[],"sources":["../../src/IsRestoringProvider.ts"],"mappings":";;cAKa;cACA,qBAAmB,MAAA"}
1
+ {"version":3,"file":"IsRestoringProvider.d.ts","names":[],"sources":["../../src/IsRestoringProvider.ts"],"mappings":";;;;;;;;;cAYa;;;;;cAMA,qBAAmB,MAAA"}
@@ -2,7 +2,18 @@
2
2
  import * as React from "react";
3
3
  //#region src/IsRestoringProvider.ts
4
4
  const IsRestoringContext = React.createContext(false);
5
+ /**
6
+ * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` hook alongside it to
7
+ * check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid
8
+ * race conditions between the restore and mounting queries.
9
+ *
10
+ * @returns `true` while a persisted client is being restored, `false` otherwise.
11
+ */
5
12
  const useIsRestoring = () => React.useContext(IsRestoringContext);
13
+ /**
14
+ * The Provider that `PersistQueryClientProvider` uses to signal whether a persisted client is currently
15
+ * being restored, read by `useIsRestoring`.
16
+ */
6
17
  const IsRestoringProvider = IsRestoringContext.Provider;
7
18
  //#endregion
8
19
  export { IsRestoringProvider, useIsRestoring };
@@ -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\nexport const useIsRestoring = () => React.useContext(IsRestoringContext)\nexport const IsRestoringProvider = IsRestoringContext.Provider\n"],"mappings":";;;AAGA,MAAM,qBAAqB,MAAM,cAAc,KAAK;AAEpD,MAAa,uBAAuB,MAAM,WAAW,kBAAkB;AACvE,MAAa,sBAAsB,mBAAmB"}
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 *\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;;;;;;;;AASpD,MAAa,uBAAuB,MAAM,WAAW,kBAAkB;;;;;AAMvE,MAAa,sBAAsB,mBAAmB"}
@@ -5,13 +5,43 @@ let react = require("react");
5
5
  react = require_rolldown_runtime.__toESM(react, 1);
6
6
  let react_jsx_runtime = require("react/jsx-runtime");
7
7
  //#region src/QueryClientProvider.tsx
8
+ /**
9
+ * The context that `useQueryClient` reads from. `QueryClientProvider` is the normal way to set it.
10
+ */
8
11
  const QueryClientContext = react.createContext(void 0);
12
+ /**
13
+ * The `useQueryClient` hook returns the current `QueryClient` instance.
14
+ *
15
+ * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
16
+ * be used.
17
+ * @returns The current `QueryClient` instance.
18
+ * @throws If no `queryClient` argument is passed and no `QueryClientProvider` is found in the component tree.
19
+ */
9
20
  const useQueryClient = (queryClient) => {
10
21
  const client = react.useContext(QueryClientContext);
11
22
  if (queryClient) return queryClient;
12
23
  if (!client) throw new Error("No QueryClient set, use QueryClientProvider to set one");
13
24
  return client;
14
25
  };
26
+ /**
27
+ * Use the `QueryClientProvider` component to connect and provide a `QueryClient` to your application. Also
28
+ * calls `client.mount()`/`client.unmount()` as this component mounts/unmounts, which subscribes the client to
29
+ * focus/online events (resuming any paused mutations and refetching as needed when the app regains focus or
30
+ * comes back online).
31
+ *
32
+ * @returns The provided `children`, wrapped so they can read the `QueryClient` via `useQueryClient`.
33
+ *
34
+ * @example
35
+ * ```tsx
36
+ * import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
37
+ *
38
+ * const queryClient = new QueryClient()
39
+ *
40
+ * function App() {
41
+ * return <QueryClientProvider client={queryClient}>...</QueryClientProvider>
42
+ * }
43
+ * ```
44
+ */
15
45
  const QueryClientProvider = ({ client, children }) => {
16
46
  react.useEffect(() => {
17
47
  client.mount();
@@ -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\nexport const QueryClientContext = React.createContext<QueryClient | undefined>(\n undefined,\n)\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\nexport type QueryClientProviderProps = {\n client: QueryClient\n children?: React.ReactNode\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":";;;;;;;AAKA,MAAa,qBAAqBA,MAAM,cACtC,KAAA,CACF;AAEA,MAAa,kBAAkB,gBAA8B;CAC3D,MAAM,SAASA,MAAM,WAAW,kBAAkB;CAElD,IAAI,aACF,OAAO;CAGT,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,wDAAwD;CAG1E,OAAO;AACT;AAOA,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"}
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 *\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 If no `queryClient` argument is passed and no `QueryClientProvider` is found in the 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 *\n * @returns The provided `children`, wrapped so they can read the `QueryClient` via `useQueryClient`.\n *\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;;;;;;;;;;;;;;;;;;;;AAqCA,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"}
@@ -1,12 +1,53 @@
1
1
  import * as React from "react";
2
2
  import { QueryClient } from "@tanstack/query-core";
3
3
  //#region src/QueryClientProvider.d.ts
4
+ /**
5
+ * The context that `useQueryClient` reads from. `QueryClientProvider` is the normal way to set it.
6
+ */
4
7
  declare const QueryClientContext: React.Context<QueryClient | undefined>;
8
+ /**
9
+ * The `useQueryClient` hook returns the current `QueryClient` instance.
10
+ *
11
+ * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
12
+ * be used.
13
+ * @returns The current `QueryClient` instance.
14
+ * @throws If no `queryClient` argument is passed and no `QueryClientProvider` is found in the component tree.
15
+ */
5
16
  declare const useQueryClient: (queryClient?: QueryClient) => QueryClient;
17
+ /**
18
+ * The props accepted by `QueryClientProvider`.
19
+ */
6
20
  type QueryClientProviderProps = {
21
+ /**
22
+ * **Required**
23
+ *
24
+ * The `QueryClient` instance to provide.
25
+ */
7
26
  client: QueryClient;
27
+ /**
28
+ * The components that get access to the provided `QueryClient`.
29
+ */
8
30
  children?: React.ReactNode;
9
31
  };
32
+ /**
33
+ * Use the `QueryClientProvider` component to connect and provide a `QueryClient` to your application. Also
34
+ * calls `client.mount()`/`client.unmount()` as this component mounts/unmounts, which subscribes the client to
35
+ * focus/online events (resuming any paused mutations and refetching as needed when the app regains focus or
36
+ * comes back online).
37
+ *
38
+ * @returns The provided `children`, wrapped so they can read the `QueryClient` via `useQueryClient`.
39
+ *
40
+ * @example
41
+ * ```tsx
42
+ * import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
43
+ *
44
+ * const queryClient = new QueryClient()
45
+ *
46
+ * function App() {
47
+ * return <QueryClientProvider client={queryClient}>...</QueryClientProvider>
48
+ * }
49
+ * ```
50
+ */
10
51
  declare const QueryClientProvider: ({ client, children }: QueryClientProviderProps) => React.JSX.Element;
11
52
  //#endregion
12
53
  export { QueryClientContext, QueryClientProvider, QueryClientProviderProps, useQueryClient };
@@ -1 +1 @@
1
- {"version":3,"file":"QueryClientProvider.d.cts","names":[],"sources":["../../src/QueryClientProvider.tsx"],"mappings":";;;cAKa,oBAAkB,MAAA,QAAA;cAIlB,iBAAkB,cAAc,gBAAW;KAc5C;EACV,QAAQ;EACR,WAAW,MAAM;;cAGN,wBAAuB,QAAA,YAGjC,6BAA2B,MAAM,IAAI"}
1
+ {"version":3,"file":"QueryClientProvider.d.cts","names":[],"sources":["../../src/QueryClientProvider.tsx"],"mappings":";;;;;;cAQa,oBAAkB,MAAA,QAAA;;;;;;;;;cAYlB,iBAAkB,cAAc,gBAAW;;;;KAiB5C;;;;;;EAMV,QAAQ;;;;EAIR,WAAW,MAAM;;;;;;;;;;;;;;;;;;;;;cAsBN,wBAAuB,QAAA,YAGjC,6BAA2B,MAAM,IAAI"}
@@ -1,12 +1,53 @@
1
1
  import * as React from "react";
2
2
  import { QueryClient } from "@tanstack/query-core";
3
3
  //#region src/QueryClientProvider.d.ts
4
+ /**
5
+ * The context that `useQueryClient` reads from. `QueryClientProvider` is the normal way to set it.
6
+ */
4
7
  declare const QueryClientContext: React.Context<QueryClient | undefined>;
8
+ /**
9
+ * The `useQueryClient` hook returns the current `QueryClient` instance.
10
+ *
11
+ * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
12
+ * be used.
13
+ * @returns The current `QueryClient` instance.
14
+ * @throws If no `queryClient` argument is passed and no `QueryClientProvider` is found in the component tree.
15
+ */
5
16
  declare const useQueryClient: (queryClient?: QueryClient) => QueryClient;
17
+ /**
18
+ * The props accepted by `QueryClientProvider`.
19
+ */
6
20
  type QueryClientProviderProps = {
21
+ /**
22
+ * **Required**
23
+ *
24
+ * The `QueryClient` instance to provide.
25
+ */
7
26
  client: QueryClient;
27
+ /**
28
+ * The components that get access to the provided `QueryClient`.
29
+ */
8
30
  children?: React.ReactNode;
9
31
  };
32
+ /**
33
+ * Use the `QueryClientProvider` component to connect and provide a `QueryClient` to your application. Also
34
+ * calls `client.mount()`/`client.unmount()` as this component mounts/unmounts, which subscribes the client to
35
+ * focus/online events (resuming any paused mutations and refetching as needed when the app regains focus or
36
+ * comes back online).
37
+ *
38
+ * @returns The provided `children`, wrapped so they can read the `QueryClient` via `useQueryClient`.
39
+ *
40
+ * @example
41
+ * ```tsx
42
+ * import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
43
+ *
44
+ * const queryClient = new QueryClient()
45
+ *
46
+ * function App() {
47
+ * return <QueryClientProvider client={queryClient}>...</QueryClientProvider>
48
+ * }
49
+ * ```
50
+ */
10
51
  declare const QueryClientProvider: ({ client, children }: QueryClientProviderProps) => React.JSX.Element;
11
52
  //#endregion
12
53
  export { QueryClientContext, QueryClientProvider, QueryClientProviderProps, useQueryClient };
@@ -1 +1 @@
1
- {"version":3,"file":"QueryClientProvider.d.ts","names":[],"sources":["../../src/QueryClientProvider.tsx"],"mappings":";;;cAKa,oBAAkB,MAAA,QAAA;cAIlB,iBAAkB,cAAc,gBAAW;KAc5C;EACV,QAAQ;EACR,WAAW,MAAM;;cAGN,wBAAuB,QAAA,YAGjC,6BAA2B,MAAM,IAAI"}
1
+ {"version":3,"file":"QueryClientProvider.d.ts","names":[],"sources":["../../src/QueryClientProvider.tsx"],"mappings":";;;;;;cAQa,oBAAkB,MAAA,QAAA;;;;;;;;;cAYlB,iBAAkB,cAAc,gBAAW;;;;KAiB5C;;;;;;EAMV,QAAQ;;;;EAIR,WAAW,MAAM;;;;;;;;;;;;;;;;;;;;;cAsBN,wBAAuB,QAAA,YAGjC,6BAA2B,MAAM,IAAI"}
@@ -2,13 +2,43 @@
2
2
  import * as React from "react";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  //#region src/QueryClientProvider.tsx
5
+ /**
6
+ * The context that `useQueryClient` reads from. `QueryClientProvider` is the normal way to set it.
7
+ */
5
8
  const QueryClientContext = React.createContext(void 0);
9
+ /**
10
+ * The `useQueryClient` hook returns the current `QueryClient` instance.
11
+ *
12
+ * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
13
+ * be used.
14
+ * @returns The current `QueryClient` instance.
15
+ * @throws If no `queryClient` argument is passed and no `QueryClientProvider` is found in the component tree.
16
+ */
6
17
  const useQueryClient = (queryClient) => {
7
18
  const client = React.useContext(QueryClientContext);
8
19
  if (queryClient) return queryClient;
9
20
  if (!client) throw new Error("No QueryClient set, use QueryClientProvider to set one");
10
21
  return client;
11
22
  };
23
+ /**
24
+ * Use the `QueryClientProvider` component to connect and provide a `QueryClient` to your application. Also
25
+ * calls `client.mount()`/`client.unmount()` as this component mounts/unmounts, which subscribes the client to
26
+ * focus/online events (resuming any paused mutations and refetching as needed when the app regains focus or
27
+ * comes back online).
28
+ *
29
+ * @returns The provided `children`, wrapped so they can read the `QueryClient` via `useQueryClient`.
30
+ *
31
+ * @example
32
+ * ```tsx
33
+ * import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
34
+ *
35
+ * const queryClient = new QueryClient()
36
+ *
37
+ * function App() {
38
+ * return <QueryClientProvider client={queryClient}>...</QueryClientProvider>
39
+ * }
40
+ * ```
41
+ */
12
42
  const QueryClientProvider = ({ client, children }) => {
13
43
  React.useEffect(() => {
14
44
  client.mount();
@@ -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\nexport const QueryClientContext = React.createContext<QueryClient | undefined>(\n undefined,\n)\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\nexport type QueryClientProviderProps = {\n client: QueryClient\n children?: React.ReactNode\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":";;;;AAKA,MAAa,qBAAqB,MAAM,cACtC,KAAA,CACF;AAEA,MAAa,kBAAkB,gBAA8B;CAC3D,MAAM,SAAS,MAAM,WAAW,kBAAkB;CAElD,IAAI,aACF,OAAO;CAGT,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,wDAAwD;CAG1E,OAAO;AACT;AAOA,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"}
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 *\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 If no `queryClient` argument is passed and no `QueryClientProvider` is found in the 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 *\n * @returns The provided `children`, wrapped so they can read the `QueryClient` via `useQueryClient`.\n *\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;;;;;;;;;;;;;;;;;;;;AAqCA,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"}
@@ -5,22 +5,98 @@ let react = require("react");
5
5
  react = require_rolldown_runtime.__toESM(react, 1);
6
6
  let react_jsx_runtime = require("react/jsx-runtime");
7
7
  //#region src/QueryErrorResetBoundary.tsx
8
+ /**
9
+ * Resets any query errors within the boundary, so queries know they can try again.
10
+ */
8
11
  function createValue() {
9
12
  let isReset = false;
10
13
  return {
14
+ /**
15
+ * Clears the reset state, so queries know not to try again until the boundary is reset again.
16
+ */
11
17
  clearReset: () => {
12
18
  isReset = false;
13
19
  },
20
+ /**
21
+ * Resets any query errors within the boundary, so queries know they can try again.
22
+ */
14
23
  reset: () => {
15
24
  isReset = true;
16
25
  },
26
+ /**
27
+ * Returns whether the boundary has been reset and not yet cleared.
28
+ */
17
29
  isReset: () => {
18
30
  return isReset;
19
31
  }
20
32
  };
21
33
  }
22
34
  const QueryErrorResetBoundaryContext = react.createContext(createValue());
35
+ /**
36
+ * This hook will reset any query errors within the closest `QueryErrorResetBoundary`. If there is no boundary
37
+ * defined it will reset them globally.
38
+ *
39
+ * @returns The boundary's {@link QueryErrorResetBoundaryValue}.
40
+ *
41
+ * @example
42
+ * ```tsx
43
+ * import { ErrorBoundary } from 'react-error-boundary'
44
+ * import { useQueryErrorResetBoundary } from '@tanstack/react-query'
45
+ *
46
+ * function App({ children }: { children: React.ReactNode }) {
47
+ * const { reset } = useQueryErrorResetBoundary()
48
+ *
49
+ * return (
50
+ * <ErrorBoundary
51
+ * onReset={reset}
52
+ * fallbackRender={({ resetErrorBoundary }) => (
53
+ * <div>
54
+ * There was an error!
55
+ * <button onClick={() => resetErrorBoundary()}>Try again</button>
56
+ * </div>
57
+ * )}
58
+ * >
59
+ * {children}
60
+ * </ErrorBoundary>
61
+ * )
62
+ * }
63
+ * ```
64
+ */
23
65
  const useQueryErrorResetBoundary = () => react.useContext(QueryErrorResetBoundaryContext);
66
+ /**
67
+ * When using `suspense` or `throwOnError` in your queries, you need a way to let queries know that you want to
68
+ * try again when re-rendering after some error occurred. With the `QueryErrorResetBoundary` component you can
69
+ * reset any query errors within the boundaries of the component.
70
+ *
71
+ * @returns The `children`, rendered as-is, or called with the boundary's {@link QueryErrorResetBoundaryValue}
72
+ * if `children` is a function.
73
+ *
74
+ * @example
75
+ * ```tsx
76
+ * import { ErrorBoundary } from 'react-error-boundary'
77
+ * import { QueryErrorResetBoundary } from '@tanstack/react-query'
78
+ *
79
+ * function App() {
80
+ * return (
81
+ * <QueryErrorResetBoundary>
82
+ * {({ reset }) => (
83
+ * <ErrorBoundary
84
+ * onReset={reset}
85
+ * fallbackRender={({ resetErrorBoundary }) => (
86
+ * <div>
87
+ * There was an error!
88
+ * <button onClick={() => resetErrorBoundary()}>Try again</button>
89
+ * </div>
90
+ * )}
91
+ * >
92
+ * <Page />
93
+ * </ErrorBoundary>
94
+ * )}
95
+ * </QueryErrorResetBoundary>
96
+ * )
97
+ * }
98
+ * ```
99
+ */
24
100
  const QueryErrorResetBoundary = ({ children }) => {
25
101
  const [value] = react.useState(() => createValue());
26
102
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(QueryErrorResetBoundaryContext.Provider, {
@@ -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 reset: QueryErrorResetFunction\n}\n\nfunction createValue(): QueryErrorResetBoundaryValue {\n let isReset = false\n return {\n clearReset: () => {\n isReset = false\n },\n reset: () => {\n isReset = true\n },\n isReset: () => {\n return isReset\n },\n }\n}\n\nconst QueryErrorResetBoundaryContext = React.createContext(createValue())\n\n// HOOK\n\nexport const useQueryErrorResetBoundary = () =>\n React.useContext(QueryErrorResetBoundaryContext)\n\n// COMPONENT\n\nexport type QueryErrorResetBoundaryFunction = (\n value: QueryErrorResetBoundaryValue,\n) => React.ReactNode\n\nexport interface QueryErrorResetBoundaryProps {\n children: QueryErrorResetBoundaryFunction | React.ReactNode\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":";;;;;;;AAcA,SAAS,cAA4C;CACnD,IAAI,UAAU;CACd,OAAO;EACL,kBAAkB;GAChB,UAAU;EACZ;EACA,aAAa;GACX,UAAU;EACZ;EACA,eAAe;GACb,OAAO;EACT;CACF;AACF;AAEA,MAAM,iCAAiCA,MAAM,cAAc,YAAY,CAAC;AAIxE,MAAa,mCACXA,MAAM,WAAW,8BAA8B;AAYjD,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
+ {"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 reset: QueryErrorResetFunction\n}\n\n/**\n * Resets any query errors within the boundary, so queries know they can try again.\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 */\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 *\n * @returns The boundary's {@link QueryErrorResetBoundaryValue}.\n *\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 *\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 *\n * @returns The `children`, rendered as-is, or called with the boundary's {@link QueryErrorResetBoundaryValue}\n * if `children` is a function.\n *\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":";;;;;;;;;;AAiBA,SAAS,cAA4C;CACnD,IAAI,UAAU;CACd,OAAO;;;;EAIL,kBAAkB;GAChB,UAAU;EACZ;;;;EAIA,aAAa;GACX,UAAU;EACZ;;;;EAIA,eAAe;GACb,OAAO;EACT;CACF;AACF;AAEA,MAAM,iCAAiCA,MAAM,cAAc,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCxE,MAAa,mCACXA,MAAM,WAAW,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DjD,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"}