-
Notifications
You must be signed in to change notification settings - Fork 786
Prevent new data re-render attempts during an existing render #3902
Conversation
This commit includes a few small `QueryData` adjustments: - Replace the `forceUpdate` callback property name with `onNewData`, to make its use more clear. - Create a small public "has SSR started" helper utility that can be used by things like the `useQuery` hook to change its behavior depending on how it's being used.
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 React Apollo, 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).
The latest `useReducer` API doesn't require an initial value.
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 good. Just left one comment for my own education.
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.
One note about the downsides of ?.
syntax, but otherwise this looks good!
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.
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.
This creates a SSR regression when used by Next.js framework. lfades/next-with-apollo#126 similar regression (SSR) when upgrading from v4 to v5 (which uses Tested on UnlyEd/next-right-now#27 I don't think it's gonna be blocking (for me) but others could run into similar issue. If so, I believe following lfades/next-with-apollo#126 (comment) is the way to go, but I'm about to try and will confirm it. |
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). PR #3902 addresses some of this, but doesn't quite catch all scenarios where this can occur. These changes take things further, ensuring that React Apollo components can't force update during a render phase.
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). PR #3902 addresses some of this, but doesn't quite catch all scenarios where this can occur. These changes take things further, ensuring that React Apollo components can't force update during a render phase.
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). PR #3902 addresses some of this, but doesn't quite catch all scenarios where this can occur. These changes take things further, ensuring that React Apollo components can't force update during a render phase.
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.
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.
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 React Apollo, this warning can be triggered when nesting multiple components that leverage
useQuery
. To help avoid this, this PR 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).Fixes #3863