Skip to content

Need help fixing sortable list animations #820

Answered by clauderic
ghost asked this question in Q&A
Discussion options

You must be logged in to vote

This is happening because the key you have provided to your SortableItems is not stable. You're currently passing in the index as a key, which causes the components to unmount and re-mount when the order of the list changes. Use the unique id of each item as a key instead, which will remain stable even when the order of the items changes.

-key={index}
+key={id}

Replies: 1 comment 1 reply

Comment options

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

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