@@ -18,6 +18,7 @@ import BarGraphComparison from './BarGraphComparison';
18
18
import { useStoreContext } from '../store' ;
19
19
// import snapshots from './snapshots';
20
20
import snapshots from './snapshots' ;
21
+ import { render } from 'react-dom' ;
21
22
22
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' ] ;
23
24
@@ -39,10 +40,6 @@ interface BarStackProps {
39
40
hierarchy : any ;
40
41
}
41
42
42
- const formatRenderTime = time => {
43
- time = time . toFixed ( 3 ) ;
44
- return `${ time } ms ` ;
45
- } ;
46
43
// function getComponentsArr(componentName, snapshots, node) {
47
44
// //Input: Name of component and all snapshots
48
45
// //Output: One array of each individual snapshot
@@ -69,7 +66,7 @@ const makePropsPretty = data => {
69
66
const nestedObj = [ ] ;
70
67
// console.log('show me the data we are getting', data);
71
68
if ( typeof data !== 'object' ) {
72
- return data ;
69
+ return < p > { data } </ p > ;
73
70
}
74
71
for ( const key in data ) {
75
72
if ( data [ key ] !== 'reactFiber' && typeof data [ key ] !== 'object' && exclude . includes ( key ) !== true ) {
@@ -98,23 +95,31 @@ const collectNodes = (snaps, componentName) => {
98
95
for ( let i = 0 ; i < snapshotList . length ; i ++ ) {
99
96
const cur = snapshotList [ i ] ;
100
97
if ( cur . name === componentName ) {
98
+ const renderTime = Number (
99
+ Number . parseFloat ( cur . componentData . actualDuration ) . toPrecision ( 5 ) ,
100
+ ) ;
101
+ if ( renderTime === 0 ) {
102
+ break ;
103
+ }
104
+ console . log ( 'show me the render time' , renderTime ) ;
101
105
// compare the last pushed component Data from the array to the current one to see if there are differences
102
106
if ( x !== 0 && componentsResult . length !== 0 ) {
103
107
// needs to be stringified because values are hard to determine if true or false if in they're seen as objects
104
108
if ( JSON . stringify ( Object . values ( componentsResult [ newChange ? componentsResult . length - 1 : trackChanges ] ) [ 0 ] ) !== JSON . stringify ( cur . componentData . props ) ) {
105
109
newChange = true ;
106
- const props = { [ `snapshot${ x } ` ] : { ... cur . componentData . props , rendertime : formatRenderTime ( cur . componentData . actualDuration ) } } ;
107
- // props[`snapshot${x}`].rendertime = formatRenderTime( cur.componentData.actualDuration) ;
110
+ // const props = { [`snapshot${x}`]: { rendertime: formatRenderTime(cur.componentData.actualDuration), ...cur.componentData.props } };
111
+ const props = { [ `snapshot${ x } ` ] : { ... cur . componentData . props } } ;
108
112
componentsResult . push ( props ) ;
109
113
} else {
110
114
newChange = false ;
111
115
trackChanges = componentsResult . length - 1 ;
112
- const props = { [ `snapshot${ x } ` ] : 'Same state as prior snapshot' , rendertime : formatRenderTime ( cur . componentData . actualDuration ) } ;
116
+ const props = { [ `snapshot${ x } ` ] : 'Same state as prior snapshot' } ;
113
117
componentsResult . push ( props ) ;
114
118
}
115
119
} else {
116
- const props = { [ `snapshot${ x } ` ] : { ...cur . componentData . props } } ;
117
- props [ `snapshot${ x } ` ] . rendertime = formatRenderTime ( cur . componentData . actualDuration ) ;
120
+ // const props = { [`snapshot${x}`]: { ...cur.componentData.props}};
121
+ // props[`snapshot${x}`].rendertime = formatRenderTime(cur.componentData.actualDuration);
122
+ const props = { [ `snapshot${ x } ` ] : { ...cur . componentData . props } } ;
118
123
componentsResult . push ( props ) ;
119
124
}
120
125
break ;
@@ -132,7 +137,7 @@ const collectNodes = (snaps, componentName) => {
132
137
componentsResult [ i ] [ componentSnapshot ] = makePropsPretty ( componentsResult [ i ] [ componentSnapshot ] ) ;
133
138
}
134
139
}
135
- console . log ( 'we should be seeing react components with information' , componentsResult ) ;
140
+ // console.log('we should be seeing react components with information', componentsResult);
136
141
return componentsResult ;
137
142
} ;
138
143
@@ -179,6 +184,12 @@ const traverse = (snapshot, data, snapshots, currTotalRender = 0) => {
179
184
// Get rtid for the hovering feature
180
185
data . componentData [ componentName ] . rtid = child . rtid ;
181
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
+ // );
182
193
// console.log('what is the result', data.componentData[componentName].information);
183
194
traverse ( snapshot . children [ idx ] , data , snapshots , currTotalRender ) ;
184
195
} ) ;
0 commit comments