Skip to content

Commit 0c243ac

Browse files
committed
replace force update hack
1 parent ab8e271 commit 0c243ac

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

lib/components/RowItem.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ class RowItem extends Component {
3333
}
3434

3535
shouldComponentUpdate(nextProps, nextState) {
36-
if (this.props.forceUpdate !== nextProps.forceUpdate) {
37-
return true
38-
}
36+
3937
if (nextProps.selectedItems !== this.props.selectedItems) {
4038
if (
4139
this.props.selectedItems.includes(this.props.item[this.props.uniqueKey]) &&
@@ -53,6 +51,26 @@ class RowItem extends Component {
5351
if (this.state.subToggled !== nextState.subToggled) {
5452
return true
5553
}
54+
55+
// propagate updates to child items
56+
// when adding/removing child items when
57+
// parent isn't selected
58+
59+
if (
60+
this.props.item[this.props.subKey] &&
61+
this.props.item[this.props.subKey].findIndex(el =>
62+
nextProps.selectedItems.includes(el[this.props.uniqueKey])) !== -1
63+
) {
64+
return true
65+
}
66+
if (
67+
this.props.item[this.props.subKey] &&
68+
this.props.item[this.props.subKey].findIndex(el =>
69+
this.props.selectedItems.includes(el[this.props.uniqueKey])) !== -1
70+
) {
71+
return true
72+
}
73+
5674
}
5775

5876
if (this.props.searchTerm !== nextProps.searchTerm) {

0 commit comments

Comments
 (0)