-
Notifications
You must be signed in to change notification settings - Fork 289
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
Fix scrolling - Beta #483
Fix scrolling - Beta #483
Conversation
Also special thanks to @ashwinb7 for helping me wrap around how React skips the update because of the shallow equal check. |
@@ -105,7 +105,7 @@ class FixedDataTableBufferedRows extends React.Component { | |||
}); | |||
} | |||
|
|||
return <div> {this._staticRowArray} </div>; |
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.
@@ -105,7 +105,7 @@ class FixedDataTableBufferedRows extends React.Component { | |||
}); | |||
} | |||
|
|||
return <div> {this._staticRowArray} </div>; | |||
return <div>{this._staticRowArray}</div>; |
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.
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.
Interesting, wow thanks for tracking this down.
Do you know if we would be able to catch this w/ a unit test if we had one which ran with a React 16 version? It may be worth ticketing out a follow up to add that.
Yea, I think we'll probably need snapshots or a way to make sure that the component got rendered into the DOM with the correct translate style or something 🤔 |
Released with v1.0.0-beta.17. |
Description
This is going to be hard to explain. Basically this fixes the issue that users mentioned in #460.
The bug only seems to affect a certain set of people, and until now we had no way of reproducing it.
Few hours ago a user created the issue (#482) , and gave a minimal sandbox.
After a lot of working around, I found out that the react version used there is
16.8.6
. If we roll it back to16.0.0-alpha.2
or less, the bug doesn't occur.Next step was finding why this was a bug only after #460. Turns out there was whitespace in the render method of
FixedDataTableBufferedRows
. As harmless as it seems, that single space (actually two of them, left and right), introduced a different render tree.Before the whitespace, the render tree was like:
After the whitespace, the render tree was like:
Now this is my understanding: after React 16, components in the tree won't be considered for rendering if the same object is passed in (checked through shallow equal comparison).
So in the first case, we take the array inside the parent div, shallow equal compare the elements, and see that they are all changed through each scroll. Hence React renders them.
In the second case, however, if we take the array inside the parent div, shallow equal compares the elements, and finds that between renders, they're all the same.
Why? The object [ array of rows ] is mutable, (see this._staticRowArray usage), and hence the object reference won't change between renders. This makes react think that the tree is static, and skips rendering. This is only seen in v16 and up (more specifically from
16.0.0-alpha.2
and above from my quick testing).Motivation and Context
Fixes #482
How Has This Been Tested?
Example site with latest React
16.8.6
Types of changes
Checklist: