Skip to content

Commit

Permalink
fix(react-query): add experimental beforeQuery/afterQuery client opti…
Browse files Browse the repository at this point in the history
…ons (#7650)
  • Loading branch information
tannerlinsley authored Jun 30, 2024
1 parent f454bf1 commit 8927e4c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 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,8 @@ export function useBaseQuery<
throw result.error
}

;(client.getDefaultOptions() as any).afterQuery?.(defaultedOptions, result)

// Handle result property usage tracking
return !defaultedOptions.notifyOnChangeProps
? observer.trackResult(result)
Expand Down

0 comments on commit 8927e4c

Please sign in to comment.