Skip to content
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

onError loop #5241

Closed
MiKaminskas opened this issue Aug 27, 2019 · 3 comments · Fixed by apollographql/react-apollo#3419
Closed

onError loop #5241

MiKaminskas opened this issue Aug 27, 2019 · 3 comments · Fixed by apollographql/react-apollo#3419

Comments

@MiKaminskas
Copy link

MiKaminskas commented Aug 27, 2019

Intended outcome:

I'm trying to set data from query to state. For It I'm using useQuery hook and useEffect. Also i need to do some action in case of error for it I'm using onError callback.

Actual outcome:

If I add callback then component is starting to loop. If I comment(or delete) this onError then it doesn't loop.

How to reproduce the issue:

I tried to reproduce this bug, but it freezes codesandbox, so I made the screenshot.
image

Versions

System:
   OS: Windows 10
 Binaries:
   Node:   10.15.1
   npm: 6.4.1 - C:\NodeJS-v10.15.1\npm.CMD
 Browsers:
   Edge: 41.16299.1004.0
   Chrome 76
 npmPackages:
   apollo-boost: ^0.4.4 => 0.4.4
   apollo-cache-inmemory: ^1.6.3 => 1.6.3
   apollo-client: ^2.6.4 => 2.6.4
   apollo-link-context: ^1.0.18 => 1.0.18
   apollo-link-http: ^1.5.15 => 1.5.15
   react-apollo: ^3.0.1 => 3.0.1

@dylanwulf
Copy link
Contributor

dylanwulf commented Aug 27, 2019

This could be related to my issue: apollographql/react-apollo#3407

I found that the problem only happens if onError or onComplete are specified as inline functions. If you define those functions as class instance methods or memoized functions then the problem stops happening.

@dylanwulf
Copy link
Contributor

I created a PR which I believe will fix this issue: apollographql/react-apollo#3419

@MiKaminskas
Copy link
Author

MiKaminskas commented Aug 28, 2019

I found that the problem only happens if onError or onComplete are specified as inline functions. If you define those functions as class instance methods or memoized functions then the problem stops happening.

I use Functional Component. In my case it help only if I move onError function outside of component. Memorized functiond didn't help.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants