@@ -11,14 +11,14 @@ import {
11
11
Switch ,
12
12
} from 'react-router-dom' ;
13
13
import { Component } from 'react' ;
14
+ import { render } from 'react-dom' ;
14
15
import RenderingFrequency from './RenderingFrequency' ;
15
16
// import Switch from '@material-ui/core/Switch';
16
17
import BarGraph from './BarGraph' ;
17
18
import BarGraphComparison from './BarGraphComparison' ;
18
19
import { useStoreContext } from '../store' ;
19
20
// import snapshots from './snapshots';
20
21
import snapshots from './snapshots' ;
21
- import { render } from 'react-dom' ;
22
22
23
23
const exclude = [ 'childExpirationTime' , 'staticContext' , '_debugSource' , 'actualDuration' , 'actualStartTime' , 'treeBaseDuration' , '_debugID' , '_debugIsCurrentlyTiming' , 'selfBaseDuration' , 'expirationTime' , 'effectTag' , 'alternate' , '_owner' , '_store' , 'get key' , 'ref' , '_self' , '_source' , 'firstBaseUpdate' , 'updateQueue' , 'lastBaseUpdate' , 'shared' , 'responders' , 'pending' , 'lanes' , 'childLanes' , 'effects' , 'memoizedState' , 'pendingProps' , 'lastEffect' , 'firstEffect' , 'tag' , 'baseState' , 'baseQueue' , 'dependencies' , 'Consumer' , 'context' , '_currentRenderer' , '_currentRenderer2' , 'mode' , 'flags' , 'nextEffect' , 'sibling' , 'create' , 'deps' , 'next' , 'destroy' , 'parentSub' , 'child' , 'key' , 'return' , 'children' , '$$typeof' , '_threadCount' , '_calculateChangedBits' , '_currentValue' , '_currentValue2' , 'Provider' , '_context' , 'stateNode' , 'elementType' , 'type' ] ;
24
24
@@ -72,7 +72,7 @@ const makePropsPretty = data => {
72
72
if ( data [ key ] !== 'reactFiber' && typeof data [ key ] !== 'object' && exclude . includes ( key ) !== true ) {
73
73
propsFormat . push ( < p className = "stateprops" >
74
74
{ `${ key } : ${ data [ key ] } ` }
75
- </ p > ) ;
75
+ </ p > ) ;
76
76
} else if ( data [ key ] !== 'reactFiber' && typeof data [ key ] === 'object' && exclude . includes ( key ) !== true ) {
77
77
const result = makePropsPretty ( data [ key ] ) ;
78
78
nestedObj . push ( result ) ;
@@ -87,6 +87,7 @@ const makePropsPretty = data => {
87
87
88
88
const collectNodes = ( snaps , componentName ) => {
89
89
const componentsResult = [ ] ;
90
+ const renderResult = [ ] ;
90
91
let trackChanges = 0 ;
91
92
let newChange = true ;
92
93
for ( let x = 0 ; x < snaps . length ; x ++ ) {
@@ -100,6 +101,8 @@ const collectNodes = (snaps, componentName) => {
100
101
) ;
101
102
if ( renderTime === 0 ) {
102
103
break ;
104
+ } else {
105
+ renderResult . push ( renderTime ) ;
103
106
}
104
107
console . log ( 'show me the render time' , renderTime ) ;
105
108
// compare the last pushed component Data from the array to the current one to see if there are differences
@@ -109,11 +112,12 @@ const collectNodes = (snaps, componentName) => {
109
112
newChange = true ;
110
113
// const props = { [`snapshot${x}`]: { rendertime: formatRenderTime(cur.componentData.actualDuration), ...cur.componentData.props } };
111
114
const props = { [ `snapshot${ x } ` ] : { ...cur . componentData . props } } ;
115
+ console . log ( 'show me props structure' , props )
112
116
componentsResult . push ( props ) ;
113
117
} else {
114
118
newChange = false ;
115
119
trackChanges = componentsResult . length - 1 ;
116
- const props = { [ `snapshot${ x } ` ] : 'Same state as prior snapshot' } ;
120
+ const props = { [ `snapshot${ x } ` ] : { state : 'Same state as prior snapshot' } } ;
117
121
componentsResult . push ( props ) ;
118
122
}
119
123
} else {
@@ -132,13 +136,23 @@ const collectNodes = (snaps, componentName) => {
132
136
}
133
137
}
134
138
// console.log('componentsResult looks like: ', componentsResult);
135
- for ( let i = 0 ; i < componentsResult . length ; i ++ ) {
136
- for ( const componentSnapshot in componentsResult [ i ] ) {
137
- componentsResult [ i ] [ componentSnapshot ] = makePropsPretty ( componentsResult [ i ] [ componentSnapshot ] ) ;
139
+
140
+ // console.log('we should be seeing react components with information', componentsResult);
141
+ // componentsResult.push(renderResult);
142
+ const finalResults = componentsResult . map ( ( e , index ) => {
143
+ const name = Object . keys ( e ) [ 0 ] ;
144
+ console . log ( 'this is name' , name , 'show me e' , e ) ;
145
+ e [ name ] . rendertime = renderResult [ index ] ;
146
+ console . log ( 'this is e' , e ) ;
147
+ return e ;
148
+ } ) ;
149
+ for ( let i = 0 ; i < finalResults . length ; i ++ ) {
150
+ for ( const componentSnapshot in finalResults [ i ] ) {
151
+ finalResults [ i ] [ componentSnapshot ] = makePropsPretty ( finalResults [ i ] [ componentSnapshot ] ) ;
138
152
}
139
153
}
140
- // console.log('we should be seeing react components with information ', componentsResult );
141
- return componentsResult ;
154
+ console . log ( 'finalresults ' , finalResults ) ;
155
+ return finalResults ;
142
156
} ;
143
157
144
158
/* DATA HANDLING HELPER FUNCTIONS */
@@ -183,14 +197,7 @@ const traverse = (snapshot, data, snapshots, currTotalRender = 0) => {
183
197
data . componentData [ componentName ] . totalRenderTime += renderTime ;
184
198
// Get rtid for the hovering feature
185
199
data . componentData [ componentName ] . rtid = child . rtid ;
186
- data . componentData [ componentName ] . information = collectNodes ( snapshots , child . name ) . flat ( Infinity ) ;
187
- if ( renderTime !== 0 ) {
188
- // eslint-disable-next-line react/jsx-one-expression-per-line
189
- data . componentData [ componentName ] . information . rendertime = < p > Render Time:{ ' ' } { renderTime } { ' ' } </ p > ;
190
- }
191
- // (
192
- // );
193
- // console.log('what is the result', data.componentData[componentName].information);
200
+ data . componentData [ componentName ] . information = collectNodes ( snapshots , child . name ) ;
194
201
traverse ( snapshot . children [ idx ] , data , snapshots , currTotalRender ) ;
195
202
} ) ;
196
203
// reassigns total render time to max render time
0 commit comments