Add virtualized indexes to itemKey
function calls
#475
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently only the real data index is passed to the
itemKey
functions for Grid and List components respectively.While this is great to be able to get an unique key for each of the rendered items, when the user scrolls, the index will change causing the new key to mismatch the previous and React to unmount and re-mount each component and, as such, recreate the DOM node.
This PR adds a new parameter to the List component
itemKey
function call,virtualizedIndex
which represents the row index relative to the first rendered row. Similarly, for Grids, there's two new properties:virtualizedRowIndex
andvirtualizedColumnIndex
.Depending on what we're optimising for, using these virtualized values instead can be a performance improvement and IMO it's quite good to have the additional option mostly when the code complexity remains pretty much the same.
Relates to: #234