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 60014f2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/react-query/src/useBaseQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export function useBaseQuery<
const errorResetBoundary = useQueryErrorResetBoundary()
const defaultedOptions = client.defaultQueryOptions(options)

;(client.getDefaultOptions() as any)._experimental_beforeQuery?.(
defaultedOptions,
)

// Make sure results are optimistically set in fetching state before subscribing or updating options
defaultedOptions._optimisticResults = isRestoring
? 'isRestoring'
Expand Down Expand Up @@ -121,6 +125,11 @@ export function useBaseQuery<
throw result.error
}

;(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 60014f2

Please sign in to comment.