Skip to content

Commit

Permalink
Fix issue Re-renders entire view when adding/removing rows
Browse files Browse the repository at this point in the history
  • Loading branch information
phuongwd committed Dec 31, 2018
1 parent 759a2ea commit 4ea0e9d
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/SortableList.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default class SortableList extends Component {

componentWillReceiveProps(nextProps) {
const {data, order} = this.state;
let {data: nextData, order: nextOrder} = nextProps;
let { data: nextData, order: nextOrder } = nextProps;

if (data && nextData && !shallowEqual(data, nextData)) {
nextOrder = nextOrder || Object.keys(nextData)
Expand All @@ -110,13 +110,33 @@ export default class SortableList extends Component {
this._resolveRowLayout[key] = resolve;
});
});
// this.setState({
// animated: false,
// data: nextData,
// containerLayout: null,
// rowsLayouts: null,
// order: nextOrder
// });



if (nextData.length > data.length) {
this.setState({
animated: false,
data: nextData,
containerLayout: null,
rowsLayouts: null,
order: nextOrder
});
} else {
this.setState({
// animated: false,
data: nextData,
// containerLayout: null,
// rowsLayouts: null,
order: nextOrder
});
}

} else if (order && nextOrder && !shallowEqual(order, nextOrder)) {
this.setState({order: nextOrder});
Expand Down

0 comments on commit 4ea0e9d

Please sign in to comment.