Skip to content

why the change from virtualItem.measureElement -> virtualizer.measureElement + data-index attr? #617

Answered by piecyk
kamikazePT asked this question in Q&A
Discussion options

You must be logged in to vote

What was the motivation for this change?

Yep, that was the case, reading the size of element when scrolling is expensive, and with not stale refs we would have extra calls

If the ref callback is defined as an inline function, it will get called twice during updates, first with null and then again with the DOM element. This is because a new instance of the function is created with each render, so React needs to clear the old ref and set up the new one. You can avoid this by defining the ref callback as a bound method on the class, but note that it shouldn’t matter in most cases.

https://reactjs-tw.github.io/docs/refs-and-the-dom.html#caveats-with-callback-refs

Plus composing two measur…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kamikazePT
Comment options

Answer selected by kamikazePT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants