react-sortablejs provides idiomatic React bindings for the powerful SortableJS drag-and-drop library, enabling developers to create interactive, sortable lists with declarative React components. It abstracts away direct DOM manipulation, integrating smoothly with React's state management. The package is currently at version 6.1.4 and receives maintenance updates focusing on bug fixes and dependency updates, though the README indicates it's "not considered ready for production". It differentiates itself by offering a ReactSortable component that directly accepts SortableJS options as props, along with supporting both functional and class-based React components and providing clear mechanisms for integrating SortableJS plugins like MultiDrag and Swap.
npm install react-sortablejsVerified import paths — ran on the pinned version, not inferred.
Demonstrates a basic sortable list using a React functional component with local state management for drag-and-drop reordering.
Thoroughly test its stability and behavior in your specific production environment. Monitor the GitHub issues for known bugs or breaking changes.
Call `Sortable.mount(new MultiDrag(), new Swap());` (or any other plugins) once in your application's bootstrap file (e.g., `index.tsx`) or at a top-level component, before rendering `<ReactSortable />`.
Always create a new array instance for `setList`. For example, use `setList(prevList => [...prevList])` or deep clone items if they are objects: `setList(newList.map(item => ({...item})))`.Update to `react-sortablejs@6.1.3` or newer to ensure full compatibility with React 18.
Call `Sortable.mount(new MultiDrag(), new Swap());` (or the relevant plugin constructors) once in your application's entry point before `<ReactSortable />` is rendered.
Use `Sortable.mount(new PluginConstructor())` for plugins. The core `SortableJS` instance is managed internally by `ReactSortable`.