-
Hi, Been trying to recreate this example But when my list changes on drop with the arrayMove helper I have a janky animation where the items jump around. I think this might be because of the rerender when using the setter from react hook. Can anyone help me fix this? Thanks. Here is a gist of my code |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This is happening because the -key={index}
+key={id} |
Beta Was this translation helpful? Give feedback.
This is happening because the
key
you have provided to yourSortableItem
s is not stable. You're currently passing in theindex
as a key, which causes the components to unmount and re-mount when the order of the list changes. Use the uniqueid
of each item as a key instead, which will remain stable even when the order of the items changes.