Skip to content

Commit d83cb4d

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

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/react-query/src/useBaseQuery.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ export function useBaseQuery<
4949
const errorResetBoundary = useQueryErrorResetBoundary()
5050
const defaultedOptions = client.defaultQueryOptions(options)
5151

52+
;(client.getDefaultOptions() as any)._experimental_beforeQuery?.(
53+
defaultedOptions,
54+
)
55+
5256
// Make sure results are optimistically set in fetching state before subscribing or updating options
5357
defaultedOptions._optimisticResults = isRestoring
5458
? 'isRestoring'
@@ -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)