@@ -24,7 +24,7 @@ import { schemeSet1 as colorScheme } from 'd3';
24
24
25
25
26
26
const PerfView = ( { snapshots, viewIndex, width = 600 , height = 600 } ) => {
27
- console . log ( '***** constructor *****' ) ;
27
+ // console.log('***** constructor *****');
28
28
const svgRef = useRef ( null ) ;
29
29
30
30
// Figure out which snapshot index to use
@@ -43,25 +43,28 @@ const PerfView = ({ snapshots, viewIndex, width = 600, height = 600 }) => {
43
43
return d3 . pack ( )
44
44
. size ( [ width , height ] )
45
45
. padding ( 3 ) ( d3 . hierarchy ( data )
46
- . sum ( d => { return d . componentData . actualDuration ; } )
46
+ . sum ( d => { return d . componentData . actualDuration || 0 ; } )
47
47
. sort ( ( a , b ) => { return b . value - a . value ; } ) ) ;
48
48
} , [ width , height ] ) ;
49
49
50
50
// If indexToDisplay changes, clear old tree nodes
51
51
useEffect ( ( ) => {
52
- console . log ( '***** useEffect - CLEARING' ) ;
52
+ // console.log('***** useEffect - CLEARING');
53
53
while ( svgRef . current . hasChildNodes ( ) ) {
54
54
svgRef . current . removeChild ( svgRef . current . lastChild ) ;
55
55
}
56
56
} , [ indexToDisplay , svgRef ] ) ;
57
57
58
58
useEffect ( ( ) => {
59
- console . log ( `***** useEffect - MAIN -> snapshots[${ indexToDisplay } ]` , snapshots [ indexToDisplay ] ) ;
59
+ // console.log(`***** useEffect - MAIN -> snapshots[${indexToDisplay}]`, snapshots[indexToDisplay]);
60
+
61
+ // Error, no App-level component present
62
+ if ( snapshots [ indexToDisplay ] . children . length < 1 ) return ;
60
63
61
64
// Generate tree with our data
62
65
const packedRoot = packFunc ( snapshots [ indexToDisplay ] ) ;
63
66
64
- // Set initial focus root node
67
+ // Set initial focus to root node
65
68
let curFocus = packedRoot ;
66
69
67
70
// View [x, y, r]
@@ -93,7 +96,7 @@ const PerfView = ({ snapshots, viewIndex, width = 600, height = 600 }) => {
93
96
. style ( 'fill-opacity' , d => ( d . parent === packedRoot ? 1 : 0 ) )
94
97
. style ( 'display' , d => ( d . parent === packedRoot ? 'inline' : 'none' ) )
95
98
. text ( d => `${ d . data . name } : \
96
- ${ Number . parseFloat ( d . data . componentData . actualDuration ) . toFixed ( 2 ) } ms` ) ;
99
+ ${ Number . parseFloat ( d . data . componentData . actualDuration || 0 ) . toFixed ( 2 ) } ms` ) ;
97
100
98
101
// Remove any unused nodes
99
102
label . exit ( ) . remove ( ) ;
@@ -115,7 +118,6 @@ const PerfView = ({ snapshots, viewIndex, width = 600, height = 600 }) => {
115
118
// Transition visibility of labels
116
119
function zoomToNode ( newFocus ) {
117
120
// console.log("zoom -> d", d);
118
-
119
121
const transition = svg . transition ( )
120
122
. duration ( d3 . event . altKey ? 7500 : 750 )
121
123
. tween ( 'zoom' , d => {
0 commit comments