-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Reduce unnecessary render() calls by ensuring ref equality with style objects #506
Conversation
objects. Adds a style objects cache to the Grid Component, which is used by the defaultCellRangeRenderer to recover previously generated styles rather than generate new objects when appropriate. This can significantly reduce the number of calls to the cell component's render() function when shallowCompare is used, because the style object will maintain referential equality.
…act-virtualized into MalucoMarinero-style-equality
@@ -701,8 +704,22 @@ export default class Grid extends Component { | |||
_enablePointerEventsAfterDelayCallback () { |
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.
Might be worth renaming this function 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.
Agreed!
Looks awesome. Curious if using an LRU cache would perform better. You wouldn't have to worry about clearing the cache on scroll end and you'd always have the viewable cell styles in cache. Either way, solid optimization! |
Sorry, haven't lost interest, more like having a week off looking after the family, but either way you guys are probably better situated to make your decisions on how to move this forward, you don't need/want any input from me yeah? |
Input is valuable, definitely. I'd welcome any you have! But family stuff is more important than coding so no worries at all. |
Also alpha-sorted, added some unit tests, fixed a small bug or two (eg reset style cache in recomputeGridSize)
c99347f
to
25293e1
Compare
FYI this optimization has been published as version 8.8.0 |
I think this has broken my code. I have List with variable-height elements. At start it renders a small "loading" element, then it renders the actual element. Even manually controlling CellMeasurer cache, it still renders the actual element (just the first one) with the same small height as the "loading" element. |
Size info has always been cached. If size changes/invalidates, you need to inform Grid via the public API method telling it that a given cell's size is invalid. I can't diagnose a brief description of a bug like this though. You should post to Stack Overflow. |
Continuation of PR #483.