File tree Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change 11/* eslint consistent-return: 0 */
22import PropTypes from 'prop-types' ;
33import React , { Component } from 'react' ;
4- import ReactDOM from 'react-dom' ;
54import SortableJS from 'sortablejs' ;
65
76const store = {
@@ -19,11 +18,13 @@ class Sortable extends Component {
1918 ] ) ,
2019 style : PropTypes . object
2120 } ;
21+
2222 static defaultProps = {
2323 options : { } ,
2424 tag : 'div' ,
2525 style : { }
2626 } ;
27+
2728 sortable = null ;
2829
2930 componentDidMount ( ) {
@@ -82,22 +83,31 @@ class Sortable extends Component {
8283 } ;
8384 } ) ;
8485
85- this . sortable = SortableJS . create ( ReactDOM . findDOMNode ( this ) , options ) ;
86+ this . sortable = SortableJS . create ( this . node , options ) ;
8687 }
88+
8789 componentWillUnmount ( ) {
8890 if ( this . sortable ) {
8991 this . sortable . destroy ( ) ;
9092 this . sortable = null ;
9193 }
9294 }
93- render ( ) {
94- const { tag : Component , ...props } = this . props ;
9595
96- delete props . options ;
97- delete props . onChange ;
96+ render ( ) {
97+ const {
98+ tag : Component ,
99+ options, // eslint-disable-line
100+ onChange, // eslint-disable-line
101+ ...props
102+ } = this . props ;
98103
99104 return (
100- < Component { ...props } />
105+ < Component
106+ { ...props }
107+ ref = { node => {
108+ this . node = node ;
109+ } }
110+ />
101111 ) ;
102112 }
103113}
You can’t perform that action at this time.
0 commit comments