Generate the list keys with the hierarchy reference #185
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.
This is a follow up to solve the issue mentioned on #175.
With this change, instead of just using the node id for the react key, two new methods were created in the Node API:
path()
: This method constructs an array that captures all the IDs in the node's hierarchy, from the root to the node itself.key()
: Thekey()
method takes the array of IDs generated bypath()
and combines them to create the actual key to be used byreact-window
'sFixedSizeList
.This change ensures that keys will remain unique, even in scenarios where data may contain nodes with the same ID under different parent nodes. By considering all ancestors in the key generation process, we prevent potential conflicts.
Keys will now look something like this if they are nested:
__REACT_ARBORIST_INTERNAL_ROOT__,12,15,15-1