-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
useQuery with inline onError function causes infinite loop #6416
Comments
Using useQuery with "network-only" fetch policy seems to also trigger a loop. |
The combination of an inline error handler and |
If you use |
I think the same issue happens with onCompleted too. |
I just encountered this and put together an example as well before I discovered this issue. As it turns out, if you return any |
Can confirm that this happens with |
This no longer works in latest stuff, but the |
This is still happening even with the official v3 release. The component infinitely rerenders and fetches if I pass an onCompleted fn. |
I believe the fix will land in the next version as it was merged only 2 days ago |
Update to |
I can confirm that with @apollo/[email protected] this is fixed. Thank You. |
As mentioned in #6416 (comment), this has been fixed. Thanks! |
Intended outcome:
Using an
onError
function withuseQuery
allows a component to recover from network errors:Actual outcome:
When a network error occurs and an inline
onError
function is defined (as show above), an infinite loop occurs, causinguseQuery
to make repeated requests indefinitely.Note: This issue does not occur when a "stable reference" to a function is supplied as a value for
onError
.How to reproduce the issue:
Reproduction on CodeSandBox
Versions
The text was updated successfully, but these errors were encountered: