0PricingLogin
React Academy · Lesson

SortableContext for Reorderable Lists

Use SortableContext and useSortable to build reorderable lists with smooth animations.

What SortableContext Does

SortableContext is a specialized dnd-kit component that wraps a reorderable list. While useDraggable and useDroppable handle arbitrary drag-and-drop, SortableContext specifically handles the case where items in a list need to be reordered by dragging them into a new position.

The items Prop

SortableContext requires an items prop: an array of unique string or number IDs that match the IDs used in the child sortable components. The order of this array defines the current order of items. When you update this array in state, the list re-renders in the new order.

All lessons in this course

  1. dnd-kit Architecture and Accessibility-First Design
  2. DndContext, useDraggable, and useDroppable
  3. SortableContext for Reorderable Lists
  4. Custom Drag Overlays and Multi-Container DnD
← Back to React Academy