Build a vertical list of tasks that the user can reorder by dragging, using the browser's native HTML5 drag-and-drop — no library. The starter App.tsx renders five task rows, each with a grip handle and draggable="true", but nothing moves yet. Your job is to wire the drag events so a row can be dropped into a new position.
Make the list reorderable:
useState so a reorder is a state update, not a DOM shuffle.dragIndex) and which row is currently under the cursor (overIndex, for the drop indicator).dragOver, call e.preventDefault() — without it the browser refuses the drop and onDrop never fires.setItems with the new order.dragging class) and the hovered row gets a green edge (over class).Review PR up onto Write tests: on drop, Review PR lands at the top and everything else shifts down.dragEnd clears the state and nothing moves.preventDefault on dragOver is mandatory. It is the single most common bug here — skip it and drops silently do nothing.<li> nodes by hand.dragStart / dragOver / drop / dragEnd, not computing coordinates.Unlock the solution & editor
Runnable editor + tests
Solve in the browser with instant Jest feedback.
Detailed solutions
Walkthroughs, edge cases, and complexity notes.
Multi-framework variants
React, Vue, Vanilla, Angular — same question, different stacks.