diff --git a/packages/react-query/src/useBaseQuery.ts b/packages/react-query/src/useBaseQuery.ts index 2eb7b614243..d6099c51871 100644 --- a/packages/react-query/src/useBaseQuery.ts +++ b/packages/react-query/src/useBaseQuery.ts @@ -96,6 +96,10 @@ export function useBaseQuery< // Handle suspense if (shouldSuspend(defaultedOptions, result)) { + ;(client.getDefaultOptions() as any)._experimental_beforeSuspend?.( + defaultedOptions, + result, + ) // Do the same thing as the effect right above because the effect won't run // when we suspend but also, the component won't re-mount so our observer would // be out of date. @@ -121,6 +125,13 @@ export function useBaseQuery< throw result.error } + if (defaultedOptions.suspense) { + ;(client.getDefaultOptions() as any)._experimental_afterSuspend?.( + defaultedOptions, + result, + ) + } + // Handle result property usage tracking return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result)