@@ -17,31 +17,44 @@ export const background = '#242529';
17
17
// children?: NodeShape[];
18
18
//
19
19
20
- function clusterDataPopulate ( props ) {
21
- let data = { } ;
20
+ const clusterData = { } ;
22
21
22
+ function clusterDataPopulate ( props ) {
23
23
console . log ( props )
24
24
let atomCompObj = reorganizedObj ( props ) ;
25
25
26
26
console . log ( atomCompObj ) ;
27
27
28
28
if ( props [ 0 ] . name ) {
29
- data . name = props [ 0 ] . name ;
29
+ clusterData . name = props [ 0 ] . name ;
30
30
}
31
31
32
+
33
+ let memoizeObj = { }
32
34
let counter = 0
35
+
33
36
for ( let key in atomCompObj ) {
34
- if ( ! data . children ) data . children = [ ]
35
- data . children . push ( { name : key } )
36
37
if ( atomCompObj [ key ] . length ) {
37
38
for ( let i = 0 ; i < atomCompObj [ key ] . length ; i ++ ) {
38
- if ( ! data . children [ counter ] . children ) data . children [ counter ] . children = [ ]
39
- data . children [ counter ] . children . push ( { name :atomCompObj [ key ] [ i ] } )
39
+
40
+
41
+
42
+
43
+
44
+ if ( ! clusterData . children ) clusterData . children = [ ]
45
+ clusterData . children . push ( { name : key } ) }
46
+ if ( ! clusterData . children [ counter ] . children ) {
47
+ clusterData . children [ counter ] . children = [ ]
48
+ clusterData . children [ counter ] . children . push ( { name :atomCompObj [ key ] [ i ] } ) }
49
+
50
+ if ( ! memoizeObj [ key ] ) {
51
+ memoizeObj [ key ] = [ ]
52
+ memoizeObj [ key ] . push [ atomCompObj [ key ] [ i ] ]
40
53
}
41
54
}
42
55
counter ++
43
56
}
44
- console . log ( data )
57
+ console . log ( clusterData )
45
58
}
46
59
47
60
function reorganizedObj ( props ) {
@@ -60,44 +73,7 @@ function reorganizedObj(props) {
60
73
return reorganizedObj ;
61
74
}
62
75
63
- const clusterData = {
64
- name : 'root' ,
65
-
66
- children : [
67
- {
68
- name : 'darkMode' ,
69
- children : [
70
- { name : 'A1' } ,
71
- { name : 'A2' } ,
72
- {
73
- name : 'C' ,
74
- children : [
75
- {
76
- name : 'C1' ,
77
- } ,
78
- ] ,
79
- } ,
80
- ] ,
81
- } ,
82
-
83
-
84
-
85
- {
86
- name : 'B' ,
87
- children : [ { name : 'B1' } , { name : 'B2' } , { name : 'B3' } ] ,
88
- } ,
89
-
90
-
91
- {
92
- name : 'X' ,
93
- children : [
94
- {
95
- name : 'Z' ,
96
- } ,
97
- ] ,
98
- } ,
99
- ] ,
100
- } ;
76
+
101
77
102
78
function Node ( { node } ) {
103
79
const isRoot = node . depth === 0 ;
0 commit comments