Skip to content

Commit 9a6e59e

Browse files
committed
refactor: also batch in suspense
1 parent 167f196 commit 9a6e59e

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

src/react/useBaseQuery.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,23 @@ export function useBaseQuery<TData, TError, TQueryFnData, TQueryData>(
1414
const errorResetBoundary = useQueryErrorResetBoundary()
1515
const defaultedOptions = queryClient.defaultQueryObserverOptions(options)
1616

17-
// Batch calls to callbacks if not in suspense mode
18-
if (!defaultedOptions.suspense) {
19-
if (defaultedOptions.onError) {
20-
defaultedOptions.onError = notifyManager.batchCalls(
21-
defaultedOptions.onError
22-
)
23-
}
17+
// Include callbacks in batch renders
18+
if (defaultedOptions.onError) {
19+
defaultedOptions.onError = notifyManager.batchCalls(
20+
defaultedOptions.onError
21+
)
22+
}
2423

25-
if (defaultedOptions.onSuccess) {
26-
defaultedOptions.onSuccess = notifyManager.batchCalls(
27-
defaultedOptions.onSuccess
28-
)
29-
}
24+
if (defaultedOptions.onSuccess) {
25+
defaultedOptions.onSuccess = notifyManager.batchCalls(
26+
defaultedOptions.onSuccess
27+
)
28+
}
3029

31-
if (defaultedOptions.onSettled) {
32-
defaultedOptions.onSettled = notifyManager.batchCalls(
33-
defaultedOptions.onSettled
34-
)
35-
}
30+
if (defaultedOptions.onSettled) {
31+
defaultedOptions.onSettled = notifyManager.batchCalls(
32+
defaultedOptions.onSettled
33+
)
3634
}
3735

3836
// Always set stale time when using suspense

0 commit comments

Comments
 (0)