Skip to content

Commit 97d9516

Browse files
committed
fix: add experimental beforeSuspend and afterSuspend queryClient options
1 parent f454bf1 commit 97d9516

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

packages/react-query/src/useBaseQuery.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ export function useBaseQuery<
9696

9797
// Handle suspense
9898
if (shouldSuspend(defaultedOptions, result)) {
99+
;(client.getDefaultOptions as any)._experimental_beforeSuspend?.(
100+
defaultedOptions,
101+
result,
102+
)
99103
// Do the same thing as the effect right above because the effect won't run
100104
// when we suspend but also, the component won't re-mount so our observer would
101105
// be out of date.
@@ -121,6 +125,13 @@ export function useBaseQuery<
121125
throw result.error
122126
}
123127

128+
if (defaultedOptions.suspense) {
129+
;(client.getDefaultOptions as any)._experimental_afterSuspend?.(
130+
defaultedOptions,
131+
result,
132+
)
133+
}
134+
124135
// Handle result property usage tracking
125136
return !defaultedOptions.notifyOnChangeProps
126137
? observer.trackResult(result)

0 commit comments

Comments
 (0)