Skip to content

Commit 6878ad7

Browse files
committed
Merge branch 'mauro-dellachiesa-master'
2 parents 191f263 + 5010662 commit 6878ad7

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/Sortable.jsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* eslint consistent-return: 0 */
22
import PropTypes from 'prop-types';
33
import React, { Component } from 'react';
4-
import ReactDOM from 'react-dom';
54
import SortableJS from 'sortablejs';
65

76
const 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
}

0 commit comments

Comments
 (0)