Skip to content

Commit de35ce5

Browse files
committed
Update README.md
1 parent 40d0577 commit de35ce5

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,34 @@ A higher order React component for [Sortable](https://github.com/RubaXa/Sortable
55
```bash
66
npm install --save react-sortablejs
77
```
8+
9+
## Usage
10+
11+
```js
12+
import SortableMixin from 'react-sortablejs';
13+
14+
const sortableOptions = {
15+
ref: 'list',
16+
model: 'items'
17+
};
18+
19+
class MySortableComponent extends React.Component {
20+
state = {
21+
items: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
22+
};
23+
24+
render() {
25+
const items = this.state.items.map((text, index) => (
26+
<li key={index}>{text}</li>
27+
));
28+
29+
return (
30+
<div>
31+
<ul ref="list">{items}</ul>
32+
</div>
33+
);
34+
}
35+
}
36+
37+
export default SortableMixin(MySortableComponent, sortableOptions);
38+
```

0 commit comments

Comments
 (0)