-
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
onCompleted is called during render phase, causing React errors (reproduction provided) #9794
Comments
…f the callback functions. Fix broken tests and add new test for the issue.
Submitted a PR which should fix this: #9801 |
@dylanwulf thanks for this, I believe I am having the same issue with I took your repo and did some modifications to test it with Could you please confirm if this is the same problem? In my actual project in order to bypass this, I had to use |
@simplecommerce I can confirm that the reproduction you provided does get fixed with the PR I submitted |
…f the callback functions. Fix broken tests and add new test for the issue.
…f the callback functions. Fix broken tests and add new test for the issue.
…f the callback functions. Fix broken tests and add new test for the issue.
…f the callback functions. Fix broken tests and add new test for the issue.
…f the callback functions. Fix broken tests and add new test for the issue.
What is the order of which onCompleted is called? Is it called sync with updating data? Or is it waited to be completed before any state updates are finished? |
Fixed by #9801! |
Intended outcome:
There should be no React errors when using apollo client
Actual outcome:
React error is printed to the console:
The cause of this seems to be that
onCompleted
gets called during the render phase if the query results are available in the cache. This can cause problems when doing something like dispatching a redux action from inside theonCompleted
function.How to reproduce the issue:
Clone and run my reproduction, using branch
react-console-errors
: https://github.com/dylanwulf/react-apollo-error-template/tree/react-console-errors. Install packages withnpm install
and run the app withnpm start
. When running the app, wait until "parent query completed" is true, then click the button and watch the console log.Versions
The text was updated successfully, but these errors were encountered: