-
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
Prevent new data re-render attempts during an existing render #6107
Conversation
Codecov Report
@@ Coverage Diff @@
## master #6107 +/- ##
==========================================
- Coverage 95.37% 95.28% -0.10%
==========================================
Files 88 88
Lines 3653 3666 +13
Branches 903 875 -28
==========================================
+ Hits 3484 3493 +9
- Misses 146 150 +4
Partials 23 23
Continue to review full report at Codecov.
|
Please hold on the review of this @benjamn. The solution implemented in apollographql/react-apollo#3902 did not fix the problem in all cases. I'm working on a more complete solution and will update this PR shortly. Thanks! |
342d8ab
to
1e7368b
Compare
@benjamn this is now ready for review. Thanks! |
Prevent new data re-render attempts during an existing render to help avoid React 16.13.0's "Cannot update a component from inside the function body of a different component" warning (facebook/react#17099). These changes were originally implemented in apollographql/react-apollo#3930.
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.
Looks great to me!
This version does *not* include my big PR #6221, which should be coming in the _next_ beta release. Code changes in beta.45 (since beta.44) include * #6194 by @durchanek * #6107 by @hwillson as well as several documentation PRs.
Don’t mind me just putting this link here for posterity (me) |
As of version 16.13.0, React logs a warning when a function component is updated during another component's render phase (facebook/react#17099). In Apollo Client this warning can be triggered when nesting multiple components that leverage
useQuery
. To help avoid this, this commit ensures re-render requests to show new data are delayed until an effect hook is run to handle them (since we're then out of the render phase).These changes were originally implemented in apollographql/react-apollo#3902.