@@ -155,7 +155,17 @@ class CheckboxTree extends React.Component {
155155 this . expandAllNodes ( false ) ;
156156 }
157157
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 ) {
159169 const flatNode = this . state . model . getNode ( node . value ) ;
160170
161171 if ( flatNode . isLeaf || noCascade ) {
@@ -173,16 +183,6 @@ class CheckboxTree extends React.Component {
173183 return 0 ;
174184 }
175185
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-
186186 isEveryChildChecked ( node ) {
187187 return node . children . every ( child => this . state . model . getNode ( child . value ) . checkState === 1 ) ;
188188 }
@@ -208,12 +208,14 @@ class CheckboxTree extends React.Component {
208208 const { icons : defaultIcons } = CheckboxTree . defaultProps ;
209209
210210 const treeNodes = nodes . map ( ( node ) => {
211- const key = ` ${ node . value } ` ;
211+ const key = node . value ;
212212 const flatNode = model . getNode ( node . value ) ;
213213 const children = flatNode . isParent ? this . renderTreeNodes ( node . children , node ) : null ;
214214
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 ) ;
217219
218220 // Show checkbox only if this is a leaf node or showCheckbox is true
219221 const showCheckbox = onlyLeafCheckboxes ? flatNode . isLeaf : flatNode . showCheckbox ;
0 commit comments