Browse Source

Reset state when component receives new props

pull/404/head
Nick Sinopoli 10 years ago
parent
commit
5633c00d19
  1. 10
      react-sortable-mixin.js

10
react-sortable-mixin.js vendored

@ -134,6 +134,16 @@
this._sortableInstance = Sortable.create((this.refs[options.ref] || this).getDOMNode(), copyOptions);
},
componentWillReceiveProps: function (nextProps) {
var newState = {},
modelName = _getModelName(this),
items;
if (items = nextProps[modelName]) {
newState[modelName] = items;
this.setState(newState);
}
},
componentWillUnmount: function () {
this._sortableInstance.destroy();

Loading…
Cancel
Save