Skip to content
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

Merged
merged 3 commits into from
Dec 14, 2016

Conversation

bvaughn
Copy link
Owner

@bvaughn bvaughn commented Dec 13, 2016

Continuation of PR #483.

MalucoMarinero and others added 2 commits November 28, 2016 11:39
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.
@@ -701,8 +704,22 @@ export default class Grid extends Component {
_enablePointerEventsAfterDelayCallback () {

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.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed!

@zackargyle
Copy link

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!

@MalucoMarinero
Copy link
Contributor

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?

@bvaughn
Copy link
Owner Author

bvaughn commented Dec 13, 2016

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)
@bvaughn bvaughn merged commit 89de97e into master Dec 14, 2016
@bvaughn bvaughn deleted the style-equality-fork branch December 14, 2016 07:15
@bvaughn
Copy link
Owner Author

bvaughn commented Dec 14, 2016

FYI this optimization has been published as version 8.8.0

@romulof
Copy link
Contributor

romulof commented Dec 20, 2016

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.

@bvaughn
Copy link
Owner Author

bvaughn commented Dec 20, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants