hard30 min

Build Drag and Drop

Build a drag-and-drop reorderable list using the HTML5 Drag and Drop API. Users should be able to drag items to reorder them within the list. Provide visual feedback during the drag operation (highlight the drop target). This exercise tests event handler coordination and state transformation.

useStateuseRefdrag eventsarray reordering
  • Renders all items in initial order
  • Items are draggable
  • Highlights the drop target during drag
  • Reorders items on drop
  • Cleans up drag state after drop
Your Code
Loading editor...