I am implementing a drag and drop effect in React.js. How do I use a custom React component or fragment (which doesn't necessarily exist yet in the DOM at the time the drag is initiated) as the drag image passed to setDragImage
, rather than a static image of the dragged item?
For example:
onDragStart = (e, index) => {
this.draggedIndex = index;
this.draggedItem = this.state.list[index];
e.dataTransfer.effectAllowed = "move";
e.dataTransfer.setData("text/html", e.target.parentNode);
e.dataTransfer.setDragImage(??????);
};
The expected result is a custom preview component.