@@ -155,7 +155,17 @@ class CheckboxTree extends React.Component {
155
155
this . expandAllNodes ( false ) ;
156
156
}
157
157
158
- getShallowCheckState ( node , noCascade ) {
158
+ expandAllNodes ( expand = true ) {
159
+ const { onExpand } = this . props ;
160
+
161
+ onExpand (
162
+ this . state . model . clone ( )
163
+ . expandAllNodes ( expand )
164
+ . serializeList ( 'expanded' ) ,
165
+ ) ;
166
+ }
167
+
168
+ determineShallowCheckState ( node , noCascade ) {
159
169
const flatNode = this . state . model . getNode ( node . value ) ;
160
170
161
171
if ( flatNode . isLeaf || noCascade ) {
@@ -173,16 +183,6 @@ class CheckboxTree extends React.Component {
173
183
return 0 ;
174
184
}
175
185
176
- expandAllNodes ( expand = true ) {
177
- const { onExpand } = this . props ;
178
-
179
- onExpand (
180
- this . state . model . clone ( )
181
- . expandAllNodes ( expand )
182
- . serializeList ( 'expanded' ) ,
183
- ) ;
184
- }
185
-
186
186
isEveryChildChecked ( node ) {
187
187
return node . children . every ( child => this . state . model . getNode ( child . value ) . checkState === 1 ) ;
188
188
}
@@ -208,12 +208,14 @@ class CheckboxTree extends React.Component {
208
208
const { icons : defaultIcons } = CheckboxTree . defaultProps ;
209
209
210
210
const treeNodes = nodes . map ( ( node ) => {
211
- const key = ` ${ node . value } ` ;
211
+ const key = node . value ;
212
212
const flatNode = model . getNode ( node . value ) ;
213
213
const children = flatNode . isParent ? this . renderTreeNodes ( node . children , node ) : null ;
214
214
215
- // Get the check state after all children check states have been determined
216
- flatNode . checkState = this . getShallowCheckState ( node , noCascade ) ;
215
+ // Determine the check state after all children check states have been determined
216
+ // This is done during rendering as to avoid an additional loop during the
217
+ // deserialization of the `checked` property
218
+ flatNode . checkState = this . determineShallowCheckState ( node , noCascade ) ;
217
219
218
220
// Show checkbox only if this is a leaf node or showCheckbox is true
219
221
const showCheckbox = onlyLeafCheckboxes ? flatNode . isLeaf : flatNode . showCheckbox ;
0 commit comments