Skip to content

Commit f49f452

Browse files
jcleighgitim
authored andcommitted
Adds conditional rendering (#139)
1 parent 477c767 commit f49f452

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.DS_Store
22
*.log
33
node_modules
4+
*.idea

src/SortableList.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,21 @@ export default class SortableList extends Component {
110110
this._resolveRowLayout[key] = resolve;
111111
});
112112
});
113-
this.setState({
114-
animated: false,
115-
data: nextData,
116-
containerLayout: null,
117-
rowsLayouts: null,
118-
order: nextOrder
119-
});
113+
114+
if (Object.keys(nextData).length > Object.keys(data).length) {
115+
this.setState({
116+
animated: false,
117+
data: nextData,
118+
containerLayout: null,
119+
rowsLayouts: null,
120+
order: nextOrder
121+
});
122+
} else {
123+
this.setState({
124+
data: nextData,
125+
order: nextOrder
126+
});
127+
}
120128

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

0 commit comments

Comments
 (0)