Skip to content

Commit c5def66

Browse files
sukvvonTkDodo
andauthored
refactor(react-query/useQueries): remove unreachable 'willFetch' branch in suspense promise collection (#10082)
* refactor(react-query/useQueries): remove unreachable 'willFetch' branch in suspense promise collection * Refactor useQueries to remove unreachable code Refactor the useQueries function to improve code clarity by removing an unreachable 'willFetch' branch in the suspense promise collection. --------- Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
1 parent ed37a87 commit c5def66

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

.changeset/wise-guests-hope.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@tanstack/react-query": patch
3+
---
4+
5+
refactor(react-query/useQueries): remove unreachable 'willFetch' branch in suspense promise collection

packages/react-query/src/useQueries.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
ensureSuspenseTimers,
2020
fetchOptimistic,
2121
shouldSuspend,
22-
willFetch,
2322
} from './suspense'
2423
import type {
2524
DefinedUseQueryResult,
@@ -294,13 +293,9 @@ export function useQueries<
294293
? optimisticResult.flatMap((result, index) => {
295294
const opts = defaultedQueries[index]
296295

297-
if (opts) {
296+
if (opts && shouldSuspend(opts, result)) {
298297
const queryObserver = new QueryObserver(client, opts)
299-
if (shouldSuspend(opts, result)) {
300-
return fetchOptimistic(opts, queryObserver, errorResetBoundary)
301-
} else if (willFetch(result, isRestoring)) {
302-
void fetchOptimistic(opts, queryObserver, errorResetBoundary)
303-
}
298+
return fetchOptimistic(opts, queryObserver, errorResetBoundary)
304299
}
305300
return []
306301
})

0 commit comments

Comments
 (0)