@@ -5,29 +5,27 @@ import {SortableContainer, SortableElement, arrayMove} from 'react-sortable-hoc'
5
5
const SortableItem = SortableElement ( ( { value} ) => < li > { value } </ li > ) ;
6
6
7
7
const SortableList = SortableContainer ( ( { items} ) => {
8
- return (
9
- < ul >
10
- { items . map ( ( value , index ) =>
11
- < SortableItem key = { `item-${ index } ` } index = { index } value = { value } />
12
- ) }
13
- </ ul >
14
- ) ;
8
+ return (
9
+ < ul >
10
+ { items . map ( ( value , index ) => (
11
+ < SortableItem key = { `item-${ index } ` } index = { index } value = { value } />
12
+ ) ) }
13
+ </ ul >
14
+ ) ;
15
15
} ) ;
16
16
17
17
class SortableComponent extends Component {
18
- state = {
19
- items : [ 'Item 1' , 'Item 2' , 'Item 3' , 'Item 4' , 'Item 5' , 'Item 6' ]
20
- }
21
- onSortEnd = ( { oldIndex, newIndex} ) => {
22
- this . setState ( {
23
- items : arrayMove ( this . state . items , oldIndex , newIndex )
24
- } ) ;
25
- } ;
26
- render ( ) {
27
- return (
28
- < SortableList items = { this . state . items } onSortEnd = { this . onSortEnd } />
29
- )
30
- }
18
+ state = {
19
+ items : [ 'Item 1' , 'Item 2' , 'Item 3' , 'Item 4' , 'Item 5' , 'Item 6' ] ,
20
+ } ;
21
+ onSortEnd = ( { oldIndex, newIndex} ) => {
22
+ this . setState ( {
23
+ items : arrayMove ( this . state . items , oldIndex , newIndex ) ,
24
+ } ) ;
25
+ } ;
26
+ render ( ) {
27
+ return < SortableList items = { this . state . items } onSortEnd = { this . onSortEnd } /> ;
28
+ }
31
29
}
32
30
33
- render ( < SortableComponent /> , document . getElementById ( 'root' ) ) ;
31
+ render ( < SortableComponent /> , document . getElementById ( 'root' ) ) ;
0 commit comments