@tanstack/react-query 5.0.0-alpha.19 → 5.0.0-alpha.21

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.
@@ -41,25 +41,6 @@ export function useBaseQuery<
41
41
  ? 'isRestoring'
42
42
  : 'optimistic'
43
43
 
44
- // Include callbacks in batch renders
45
- if (defaultedOptions.onError) {
46
- defaultedOptions.onError = notifyManager.batchCalls(
47
- defaultedOptions.onError,
48
- )
49
- }
50
-
51
- if (defaultedOptions.onSuccess) {
52
- defaultedOptions.onSuccess = notifyManager.batchCalls(
53
- defaultedOptions.onSuccess,
54
- )
55
- }
56
-
57
- if (defaultedOptions.onSettled) {
58
- defaultedOptions.onSettled = notifyManager.batchCalls(
59
- defaultedOptions.onSettled,
60
- )
61
- }
62
-
63
44
  ensureStaleTime(defaultedOptions)
64
45
  ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary)
65
46
 
package/src/useQueries.ts CHANGED
@@ -166,6 +166,7 @@ export function useQueries<T extends any[]>(
166
166
  ): QueriesResults<T> {
167
167
  const client = useQueryClient(queryClient)
168
168
  const isRestoring = useIsRestoring()
169
+ const errorResetBoundary = useQueryErrorResetBoundary()
169
170
 
170
171
  const defaultedQueries = React.useMemo(
171
172
  () =>
@@ -182,6 +183,13 @@ export function useQueries<T extends any[]>(
182
183
  [queries, client, isRestoring],
183
184
  )
184
185
 
186
+ defaultedQueries.forEach((query) => {
187
+ ensureStaleTime(query)
188
+ ensurePreventErrorBoundaryRetry(query, errorResetBoundary)
189
+ })
190
+
191
+ useClearResetErrorBoundary(errorResetBoundary)
192
+
185
193
  const [observer] = React.useState(
186
194
  () => new QueriesObserver(client, defaultedQueries),
187
195
  )
@@ -206,15 +214,6 @@ export function useQueries<T extends any[]>(
206
214
  observer.setQueries(defaultedQueries, { listeners: false })
207
215
  }, [defaultedQueries, observer])
208
216
 
209
- const errorResetBoundary = useQueryErrorResetBoundary()
210
-
211
- defaultedQueries.forEach((query) => {
212
- ensurePreventErrorBoundaryRetry(query, errorResetBoundary)
213
- ensureStaleTime(query)
214
- })
215
-
216
- useClearResetErrorBoundary(errorResetBoundary)
217
-
218
217
  const shouldAtLeastOneSuspend = optimisticResult.some((result, index) =>
219
218
  shouldSuspend(defaultedQueries[index], result, isRestoring),
220
219
  )
@@ -238,14 +237,14 @@ export function useQueries<T extends any[]>(
238
237
  if (suspensePromises.length > 0) {
239
238
  throw Promise.all(suspensePromises)
240
239
  }
241
-
240
+ const observerQueries = observer.getQueries()
242
241
  const firstSingleResultWhichShouldThrow = optimisticResult.find(
243
242
  (result, index) =>
244
243
  getHasError({
245
244
  result,
246
245
  errorResetBoundary,
247
246
  throwErrors: defaultedQueries[index]?.throwErrors ?? false,
248
- query: observer.getQueries()[index]!,
247
+ query: observerQueries[index]!,
249
248
  }),
250
249
  )
251
250