Skip to content

Why doesn't keyExtractor return an index anymore? #316

Answered by MatiPl01
fax1ty asked this question in Q&A
Discussion options

You must be logged in to vote

Why doesn't keyExtractor return an index anymore?

It doesn't because of problems that it introduced. In general, items were incorrectly positioned after a new data array was provided containing items in a different order than before. Because keys were assigned based on index, thus they weren't related to the item itself, we could observer incorrect animations e.g. during view addition/removal - see the example below:

key related to item (e.g. id prop) (correct) index key (incorrect)
Screen.Recording.2025-03-25.at.00.39.51.mp4
Screen.Recording.2025-03-25.at.00.39.24.mp4

You included comparison of 2 keyExtractor implementations. Did you use the first one with…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@fax1ty
Comment options

@fax1ty
Comment options

@MatiPl01
Comment options

@fax1ty
Comment options

@MatiPl01
Comment options

Answer selected by fax1ty
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