Skip to content

Commit e45d6e5

Browse files
committed
reduce calls of componentdidUpdate
1 parent c334eed commit e45d6e5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/index.jsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,13 @@ const SortableMixin = (options = defaultOptions) => (Component) => class extends
119119
sortableComponent.setState(newState);
120120
}
121121
}
122-
componentDidUpdate() {
123-
this.initSortable(this.refs[refName]);
122+
componentDidUpdate(prevProps) {
123+
const model = this.sortableOptions.model;
124+
const prevItems = prevProps[model];
125+
const currItems = this.props[model];
126+
if(prevItems !== currItems) {
127+
this.initSortable(this.refs[refName]);
128+
}
124129
}
125130
componentWillUnmount() {
126131
this.destroySortable();

0 commit comments

Comments
 (0)