From 74800d96b2b26c3e6c674c5a3453dfc4bacc9273 Mon Sep 17 00:00:00 2001 From: jcleigh Date: Thu, 3 Jan 2019 06:40:52 -0600 Subject: [PATCH] Adds conditional rendering --- .gitignore | 1 + src/SortableList.js | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index d7e3a4e..ae323d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store *.log node_modules +*.idea diff --git a/src/SortableList.js b/src/SortableList.js index be7d2d0..942ecf1 100644 --- a/src/SortableList.js +++ b/src/SortableList.js @@ -110,13 +110,21 @@ export default class SortableList extends Component { this._resolveRowLayout[key] = resolve; }); }); - this.setState({ - animated: false, - data: nextData, - containerLayout: null, - rowsLayouts: null, - order: nextOrder - }); + + if (Object.keys(nextData).length > Object.keys(data).length) { + this.setState({ + animated: false, + data: nextData, + containerLayout: null, + rowsLayouts: null, + order: nextOrder + }); + } else { + this.setState({ + data: nextData, + order: nextOrder + }); + } } else if (order && nextOrder && !shallowEqual(order, nextOrder)) { this.setState({order: nextOrder});