react-treebeard icon indicating copy to clipboard operation
react-treebeard copied to clipboard

Animation does not work without item id.

Open dotneet opened this issue 6 years ago • 4 comments

As he mentioned in the comment below, animations does not work without item id. https://github.com/storybookjs/react-treebeard/issues/223#issuecomment-507031668

dotneet avatar Jul 02 '19 05:07 dotneet

@maximilianoforlenza Thank you for maintaining very useful package. I found out that this change breaks animation.

https://github.com/storybookjs/react-treebeard/commit/f8eec1ed4078a0e94cfb3c824675f9a251319dba

Why use randomString() instead of index?

dotneet avatar Jul 02 '19 06:07 dotneet

Because index as a key is an anti-pattern

maximilianoforlenza avatar Jul 02 '19 07:07 maximilianoforlenza

That's correct. But using randomString() in rendering time does not resolve any problem that index as a key cause. Because keys are changed every rendering time.

Ideally the key for a same data must be same every rendering time. If it's not possible, using index as a key is better choice than randomString().

dotneet avatar Jul 02 '19 07:07 dotneet

Is there any work around for this? Currently I'm adding .id to my nodes in the collection so that the animation is working. But I would prefer to use their ._id or have randomString() work with animations.

@maximilianoforlenza , thanks for an awesome package!

FilipHarald avatar Apr 07 '20 06:04 FilipHarald