Skip to content

Commit dacd085

Browse files
committed
Do not mutate properties
1 parent 35dcdbe commit dacd085

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/js/Tree.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Tree extends React.Component {
2121
}
2222

2323
onCheck(node) {
24-
const { checked } = this.props;
24+
const checked = [...this.props.checked];
2525
const isChecked = node.checked;
2626

2727
this.setCheckState(checked, node, isChecked);
@@ -31,7 +31,7 @@ class Tree extends React.Component {
3131

3232
onExpand(node) {
3333
const isExpanded = node.expanded;
34-
const expanded = this.props.expanded;
34+
const expanded = [...this.props.expanded];
3535
const nodeIndex = expanded.indexOf(node.value);
3636

3737
if (!isExpanded && nodeIndex > -1) {
@@ -119,7 +119,7 @@ class Tree extends React.Component {
119119
}
120120

121121
hasChildren(node) {
122-
if (typeof node.children !== 'object') {
122+
if (node.children === undefined) {
123123
return false;
124124
}
125125

0 commit comments

Comments
 (0)