@tanstack/react-query 4.29.1 → 4.29.3

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/src/useQueries.ts CHANGED
@@ -157,6 +157,7 @@ export function useQueries<T extends any[]>({
157
157
  }): QueriesResults<T> {
158
158
  const queryClient = useQueryClient({ context })
159
159
  const isRestoring = useIsRestoring()
160
+ const errorResetBoundary = useQueryErrorResetBoundary()
160
161
 
161
162
  const defaultedQueries = React.useMemo(
162
163
  () =>
@@ -173,6 +174,13 @@ export function useQueries<T extends any[]>({
173
174
  [queries, queryClient, isRestoring],
174
175
  )
175
176
 
177
+ defaultedQueries.forEach((query) => {
178
+ ensureStaleTime(query)
179
+ ensurePreventErrorBoundaryRetry(query, errorResetBoundary)
180
+ })
181
+
182
+ useClearResetErrorBoundary(errorResetBoundary)
183
+
176
184
  const [observer] = React.useState(
177
185
  () => new QueriesObserver(queryClient, defaultedQueries),
178
186
  )
@@ -197,15 +205,6 @@ export function useQueries<T extends any[]>({
197
205
  observer.setQueries(defaultedQueries, { listeners: false })
198
206
  }, [defaultedQueries, observer])
199
207
 
200
- const errorResetBoundary = useQueryErrorResetBoundary()
201
-
202
- defaultedQueries.forEach((query) => {
203
- ensurePreventErrorBoundaryRetry(query, errorResetBoundary)
204
- ensureStaleTime(query)
205
- })
206
-
207
- useClearResetErrorBoundary(errorResetBoundary)
208
-
209
208
  const shouldAtLeastOneSuspend = optimisticResult.some((result, index) =>
210
209
  shouldSuspend(defaultedQueries[index], result, isRestoring),
211
210
  )
@@ -229,14 +228,14 @@ export function useQueries<T extends any[]>({
229
228
  if (suspensePromises.length > 0) {
230
229
  throw Promise.all(suspensePromises)
231
230
  }
232
-
231
+ const observerQueries = observer.getQueries()
233
232
  const firstSingleResultWhichShouldThrow = optimisticResult.find(
234
233
  (result, index) =>
235
234
  getHasError({
236
235
  result,
237
236
  errorResetBoundary,
238
237
  useErrorBoundary: defaultedQueries[index]?.useErrorBoundary ?? false,
239
- query: observer.getQueries()[index]!,
238
+ query: observerQueries[index]!,
240
239
  }),
241
240
  )
242
241