@@ -19,6 +19,7 @@ See more options at https://github.com/RubaXa/Sortable#options
1919## Usage
2020
2121``` js
22+ import React from ' react' ;
2223import SortableMixin from ' react-sortablejs' ;
2324
2425const sortableOptions = {
@@ -46,3 +47,80 @@ class MySortableComponent extends React.Component {
4647
4748export default SortableMixin (MySortableComponent, sortableOptions);
4849```
50+
51+ ## Examples
52+
53+ Using the ` group ` option to drag elements from one list into another.
54+
55+ File: index.jsx
56+ ``` js
57+ import React from ' react' ;
58+ import Sortable1 from ' ./sortable1' ;
59+ import Sortable1 from ' ./sortable2' ;
60+
61+ const SortableList = (props ) => {
62+ return (
63+ < div>
64+ < Sortable1 / >
65+ < hr / >
66+ < Sortable2 / >
67+ < / div>
68+ );
69+ };
70+
71+ React .render (< SortableList / > , document .body );
72+ ```
73+
74+ File: sortable1.jsx
75+
76+ ``` js
77+ import React from ' react' ;
78+ import SortableMixin from ' react-sortablejs' ;
79+
80+ class Sortable1 extends React .Component {
81+ state = {
82+ items: [0 , 1 , 2 , 3 , 4 ]
83+ };
84+
85+ render () {
86+ let items = this .state .items .map ((text , index ) => {
87+ return < li key= {index}> {text}< / li> ;
88+ });
89+
90+ return (
91+ < div>
92+ < ul ref= " list" > {items}< / ul>
93+ < / div>
94+ );
95+ }
96+ }
97+
98+ export default SortableMixin (Sortable1, { group: ' shared' });
99+ ```
100+
101+ File: sortable2.jsx
102+
103+ ``` js
104+ import React from ' react' ;
105+ import SortableMixin from ' react-sortablejs' ;
106+
107+ class Sortable2 extends React .Component {
108+ state = {
109+ items: [5 , 6 , 7 , 8 , 9 ]
110+ };
111+
112+ render () {
113+ let items = this .state .items .map ((text , index ) => {
114+ return < li key= {index}> {text}< / li> ;
115+ });
116+
117+ return (
118+ < div>
119+ < ul ref= " list" > {items}< / ul>
120+ < / div>
121+ );
122+ }
123+ }
124+
125+ export default SortableMixin (Sortable2, { group: ' shared' });
126+ ```
0 commit comments