I'm trying to create a controlled grid with widgets as items, unfortunately I run into a problem that I can't find the solution to.
Every time I remove an item(widget), the whole grid seems to be rerendered and hence the remaining items(widgets) get animated as if the first render was happening.
I've checked, and apparently the animation happens for the items that come after the one being deleted in the state array (widgets). So if you delete the last item, the two remaining will not be animated. If you delete the second item, only the last item will be animated. And if you delete the first one, the other two will be animated.
Expected behavior
The item should be removed, but the animation shouldn't happen. I suspect it maybe that the items may be being rerendered by the useEffect hook with the makeWidget.
Subject of the issue
I'm trying to create a controlled grid with widgets as items, unfortunately I run into a problem that I can't find the solution to. Every time I remove an item(widget), the whole grid seems to be rerendered and hence the remaining items(widgets) get animated as if the first render was happening.
Your environment
Steps to reproduce
The actual codebase is much more complex so I tried reducing the code as much as possible. To reproduce, simply remove an item (by hovering over the item and clicking on the trash bin icon on the top left corner) from the grid and see how the remaining items get animated into their current position. https://stackblitz.com/~/edit/stackblitz-starters-xz2qaa?description=The+React+framework+for+production
I've checked, and apparently the animation happens for the items that come after the one being deleted in the state array (widgets). So if you delete the last item, the two remaining will not be animated. If you delete the second item, only the last item will be animated. And if you delete the first one, the other two will be animated.
Expected behavior
The item should be removed, but the animation shouldn't happen. I suspect it maybe that the items may be being rerendered by the useEffect hook with the
makeWidget
.