react-sortablejs
A React component built on top of Sortable.
Notice
There is a major breaking change since v1.0. Checkout Migration Guide while upgrading from earlier versions.
Installation
Webpack or Browserify
The easiest way to use react-sortablejs is to install it from npm and include it in your React build process using webpack or browserify.
Checkout the examples directory for a complete setup.
Standalone ES5 module
You can create a standalone ES5 module as shown below:
Then, include these scripts into your html file:
Use <ReactSortable /> instead of <Sortable /> in your JSX code since the Sortable library will export a window.Sortable object if you're running JSX code directly in the browser. For example:
Usage
File: sortable-list.jsx
File: index.jsx
Examples
Uncontrolled Component
An uncontrolled component allows Sortable to touch DOM nodes. It's useful when you don't need to maintain any state changes.
Controlled Component
A controlled component will keep DOM nodes untouched. You have to change state to re-render the component.
Shared Group
An example of using the group
option to drag elements from one list into another.
File: shared-group.jsx
File: index.jsx