File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -92,13 +92,17 @@ export const CollectionNode: React.FC<CollectionNodeProps> = (props) => {
92
92
// the animation transition when opening and closing the accordion
93
93
const hasBeenOpened = useRef ( ! startCollapsed )
94
94
95
+ // DERIVED VALUES (this makes the JSX conditional logic easier to follow
96
+ // further down)
97
+ const { isEditing, isEditingKey, isArray, canEditKey } = derivedValues
98
+
95
99
useEffect ( ( ) => {
96
100
setStringifiedValue ( jsonStringify ( data ) )
97
101
if ( isEditing ) setCurrentlyEditingElement ( null )
98
102
} , [ data ] )
99
103
100
104
useEffect ( ( ) => {
101
- const shouldBeCollapsed = collapseFilter ( nodeData ) && ! derivedValues . isEditing
105
+ const shouldBeCollapsed = collapseFilter ( nodeData ) && ! isEditing
102
106
hasBeenOpened . current = ! shouldBeCollapsed
103
107
animateCollapse ( shouldBeCollapsed )
104
108
} , [ collapseFilter ] )
@@ -235,8 +239,6 @@ export const CollectionNode: React.FC<CollectionNodeProps> = (props) => {
235
239
setStringifiedValue ( jsonStringify ( data ) )
236
240
}
237
241
238
- // DERIVED VALUES (this makes the JSX conditional logic easier to follow)
239
- const { isEditing, isEditingKey, isArray, canEditKey } = derivedValues
240
242
const showLabel = showArrayIndices || ! isArray
241
243
const showCount = showCollectionCount === 'when-closed' ? collapsed : showCollectionCount
242
244
const showEditButtons = ! isEditing && showEditTools
You can’t perform that action at this time.
0 commit comments