-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
Don't diff memoized host components in completion phase #13423
Conversation
@@ -357,8 +357,8 @@ exports[`ReactDebugFiberPerf skips parents during setState 1`] = ` | |||
|
|||
⚛ (Committing Changes) | |||
⚛ (Committing Snapshot Effects: 0 Total) | |||
⚛ (Committing Host Effects: 6 Total) | |||
⚛ (Calling Lifecycle Methods: 6 Total) |
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.
Should have spotted this earlier. Sigh.
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.
Is this just way more efficient now?
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.
I think not — I think it was still overcounting actual updates (not entirely sure why). But it's better.
Details of bundled changes.Comparing: d14e443...0a477d8 react-noop-renderer
Generated by 🚫 dangerJS |
@@ -361,6 +361,10 @@ function completeWork( | |||
// If we have an alternate, that means this is an update and we need to | |||
// schedule a side-effect to do the updates. | |||
const oldProps = current.memoizedProps; | |||
if (oldProps === newProps) { | |||
break; |
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.
Be careful with those early returns. I think you’re skipping the ref changing.
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.
Can it even change if we bail out?
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.
I'll push up a fix tho.
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.
In theory we can have a different element with the same props object.
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.
Seems legit
Fixes #13425.
View without whitespace: https://github.com/facebook/react/pull/13423/files?w=1
The bigger issue (#13424) is still a problem but it has always been broken (I checked as far as 0.11). Here I'm only fixing the regression in React 16 that made this a problem even when
setState
calls are in different components.In particular, we shouldn't be diffing host components that are outside of
setState
path.Some indentation changes are due to tests I tweaked but they're unrelated. The only change there is to consistently add and remove
container
from the document. The real changes are only in the newly added test at the bottom, and inCompleteWork
.