Skip to content

Reorder animation on FlatList items using itemLayoutAnimation prop #6322

Answered by MatiPl01
dawid-bytys asked this question in Q&A
Discussion options

You must be logged in to vote

Hey!
Thank you for noticing the issue. It turns out that you need to add the keyExtractor property to your Animated.FlatList if your list items have neither the id nor the key property.
In general, the default keyExtractor in react native looks for only these 2 properties in your list items. If neither of these exists, you should provide your own implementation for efficient list items updated. It looks like itemLayoutAnimation also needs to know item keys. In your case, the following implementation of keyExtractor will fix the issue:

keyExtractor={(item) => item}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@MatiPl01
Comment options

@MatiPl01
Comment options

Answer selected by dawid-bytys
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