@@ -76,7 +76,7 @@ const SortableList = ({ items, onChange }) => {
7676 tag= " ul"
7777
7878 // [Optional] The onChange method allows you to implement a controlled component and keep
79- // DOM nodes untouched. You have to change state to re-render the children .
79+ // DOM nodes untouched. You have to change state to re-render the component .
8080 onChange= {(order ) => {
8181 onChange (order);
8282 }}
@@ -127,7 +127,9 @@ ReactDOM.render(
127127
128128## Examples
129129
130- ### 1. Uncontrolled Component
130+ ### Uncontrolled Component
131+ An uncontrolled component allows Sortable to touch DOM nodes. It's useful when you don't need to maintain state change.
132+
131133``` js
132134import React from ' react' ;
133135import ReactDOM from ' react-dom' ;
@@ -159,7 +161,8 @@ ReactDOM.render(
159161);
160162```
161163
162- ### 2. Controlled Component
164+ ### Controlled Component
165+ A controlled component will keep DOM nodes untouched. You have to change state to re-render the component.
163166
164167``` js
165168import React from ' react' ;
@@ -195,37 +198,15 @@ ReactDOM.render(
195198);
196199```
197200
198- ### 3. Shared Group
199- Using the ` group ` option to drag elements from one list into another.
200-
201- File: index.jsx
202- ``` js
203- import React from ' react' ;
204- import ReactDOM from ' react-dom' ;
205- import SharedGroup from ' ./shared-group' ;
206-
207- const App = (props ) => {
208- return (
209- < div>
210- < SharedGroup
211- items= {[' Apple' , ' Banaba' , ' Cherry' , ' Grape' ]}
212- / >
213- < br/ >
214- < SharedGroup
215- items= {[' Lemon' , ' Orange' , ' Pear' , ' Peach' ]}
216- / >
217- < / div>
218- );
219- };
220-
221- ReactDOM .render (< App / > , document .getElementById (' container' ));
222- ```
201+ ### Shared Group
202+ An example of using the ` group ` option to drag elements from one list into another.
223203
224204File: shared-group.jsx
225205``` js
226206import React from ' react' ;
227207import Sortable from ' ../src' ;
228208
209+ // Functional Component
229210const SharedGroup = ({ items }) => {
230211 items = items .map ((val , key ) => (< li key= {key} data- id= {val}> {val}< / li> ));
231212
@@ -244,3 +225,26 @@ const SharedGroup = ({ items }) => {
244225
245226export default SharedGroup ;
246227```
228+
229+ File: index.jsx
230+ ``` js
231+ import React from ' react' ;
232+ import ReactDOM from ' react-dom' ;
233+ import SharedGroup from ' ./shared-group' ;
234+
235+ const App = (props ) => {
236+ return (
237+ < div>
238+ < SharedGroup
239+ items= {[' Apple' , ' Banaba' , ' Cherry' , ' Grape' ]}
240+ / >
241+ < br/ >
242+ < SharedGroup
243+ items= {[' Lemon' , ' Orange' , ' Pear' , ' Peach' ]}
244+ / >
245+ < / div>
246+ );
247+ };
248+
249+ ReactDOM .render (< App / > , document .getElementById (' container' ));
250+ ```
0 commit comments