-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
fix(react-query): allow retryOnMount when throwOnError is function (#9336) #9338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(react-query): allow retryOnMount when throwOnError is function (#9336) #9338
Conversation
…cases When throwOnError is a function, allow retryOnMount to proceed even when error boundary hasn't reset, while maintaining the prevention behavior for boolean throwOnError values.
options.experimental_prefetchInRender | ||
) { | ||
// Prevent retrying failed query if the error boundary has not been reset yet | ||
if (!errorResetBoundary.isReset()) { | ||
options.retryOnMount = false | ||
} | ||
} else if (options.throwOnError) { | ||
if (!errorResetBoundary.isReset() && typeof options.throwOnError !== 'function') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function can return true or false so I think we'd need to evaluate it to get the result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to evaluate the throwOnError function result instead of just checking if it's a function. Thanks for the feedback!
Refine behavior to handle function-type throwOnError, allowing retries when appropriate. Ensure boolean throwOnError values still prevent retries when the error boundary isn't reset.
This commit introduces tests to verify the behavior of the `throwOnError` callback in scenarios where `retryOnMount` is enabled. It ensures proper handling of retries based on the error state and the `throwOnError` function's return value. These tests improve the reliability and coverage of error handling logic in `useQuery`.
- Pass query object to ensurePreventErrorBoundaryRetry for accurate state checking - Preserve query deduplication behavior while fixing throwOnError function handling - Fixes issue where throwOnError function couldn't access query error state
f7b90c2
to
9c8516d
Compare
Fixed #9336
Summary