Skip to content

Commit c334eed

Browse files
committed
redundant code
1 parent 64bc7cb commit c334eed

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/index.jsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,18 @@ const SortableMixin = (options = defaultOptions) => (Component) => class extends
123123
this.initSortable(this.refs[refName]);
124124
}
125125
componentWillUnmount() {
126-
if (this.sortableInstance) {
127-
this.sortableInstance.destroy();
128-
this.sortableInstance = null;
129-
}
126+
this.destroySortable();
130127
}
131128
initSortable(sortableComponent) {
129+
this.destroySortable();
130+
const domNode = ReactDOM.findDOMNode(sortableComponent.refs[this.sortableOptions.ref] || sortableComponent);
131+
this.sortableInstance = Sortable.create(domNode, this.populatedOptions);
132+
}
133+
destroySortable() {
132134
if (this.sortableInstance) {
133135
this.sortableInstance.destroy();
134136
this.sortableInstance = null;
135137
}
136-
const domNode = ReactDOM.findDOMNode(sortableComponent.refs[this.sortableOptions.ref] || sortableComponent);
137-
this.sortableInstance = Sortable.create(domNode, this.populatedOptions);
138138
}
139139

140140
render() {

0 commit comments

Comments
 (0)