Skip to content

Commit

Permalink
fix: add experimental beforeSuspend and afterSuspend queryClient options
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerlinsley committed Jun 30, 2024
1 parent f454bf1 commit 9e16b9a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/react-query/src/useBaseQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down

0 comments on commit 9e16b9a

Please sign in to comment.