react-sortable-hoc icon indicating copy to clipboard operation
react-sortable-hoc copied to clipboard

Dragged element renders with stale props during drag

Open david-arteaga opened this issue 5 years ago • 0 comments

When dragging an element, the element does not re-render even if props change while it is being dragged.

I'm not sure if it has something to do with the way the floating dragged element that follows the mouse is rendered, but that is the item that does not re-render even when it should.

If I set the hideSortableGhost to false, the non-animated item does get re-rendered appropriately, so my guess is the floating dragged item is some sort of snapshot of the item on drag start.

Reproduction

https://codesandbox.io/s/react-sortable-hoc-stale-props-on-drag-jjeoz

I included a use case in the codesandbox, in which an item has to render some "separator" or "joining" UI to join it to the list item above it, only if there is one. I want to reflect this condition visually as soon as the user starts dragging, which in practice means that "separator" component should get shown and hidden if a list item becomes/stops being the first item in the list.

david-arteaga avatar Nov 10 '20 22:11 david-arteaga