9
9
10
10
import * as React from 'react' ;
11
11
import { Fragment , useContext } from 'react' ;
12
+
13
+ import InspectedElementBadges from '../Components/InspectedElementBadges' ;
12
14
import { ProfilerContext } from './ProfilerContext' ;
13
15
import { formatDuration } from './utils' ;
14
16
import WhatChanged from './WhatChanged' ;
@@ -34,11 +36,21 @@ export default function HoveredFiberInfo({fiberData}: Props): React.Node {
34
36
const { id, name} = fiberData ;
35
37
const { profilingCache} = profilerStore ;
36
38
39
+ if ( rootID === null || selectedCommitIndex === null ) {
40
+ return null ;
41
+ }
42
+
37
43
const commitIndices = profilingCache . getFiberCommits ( {
38
- fiberID : ( ( id : any ) : number ) ,
39
- rootID : ( ( rootID : any ) : number ) ,
44
+ fiberID : id ,
45
+ rootID,
40
46
} ) ;
41
47
48
+ const { nodes} = profilingCache . getCommitTree ( {
49
+ rootID,
50
+ commitIndex : selectedCommitIndex ,
51
+ } ) ;
52
+ const node = nodes . get ( id ) ;
53
+
42
54
let renderDurationInfo = null ;
43
55
let i = 0 ;
44
56
for ( i = 0 ; i < commitIndices . length ; i ++ ) {
@@ -51,7 +63,8 @@ export default function HoveredFiberInfo({fiberData}: Props): React.Node {
51
63
52
64
renderDurationInfo = (
53
65
< div key = { commitIndex } className = { styles . CurrentCommit } >
54
- { formatDuration ( selfDuration ) } ms of { formatDuration ( actualDuration ) } ms
66
+ < strong > Duration:</ strong > { formatDuration ( selfDuration ) } ms of{ ' ' }
67
+ { formatDuration ( actualDuration ) } ms
55
68
</ div >
56
69
) ;
57
70
@@ -63,10 +76,27 @@ export default function HoveredFiberInfo({fiberData}: Props): React.Node {
63
76
< Fragment >
64
77
< div className = { styles . Toolbar } >
65
78
< div className = { styles . Component } > { name } </ div >
66
- </ div >
67
- < div className = { styles . Content } >
68
- { renderDurationInfo || < div > Did not render.</ div > }
69
- < WhatChanged fiberID = { ( ( id : any ) : number ) } />
79
+
80
+ { node != null && (
81
+ < div className = { styles . BadgesContainer } >
82
+ < InspectedElementBadges
83
+ hocDisplayNames = { node . hocDisplayNames }
84
+ compiledWithForget = { node . compiledWithForget }
85
+ />
86
+
87
+ { node . compiledWithForget && (
88
+ < div >
89
+ ✨ This component has been auto-memoized by the React Compiler.
90
+ </ div >
91
+ ) }
92
+ </ div >
93
+ ) }
94
+
95
+ < div className = { styles . Content } >
96
+ { renderDurationInfo || < div > Did not render.</ div > }
97
+
98
+ < WhatChanged fiberID = { id } />
99
+ </ div >
70
100
</ div >
71
101
</ Fragment >
72
102
) ;
0 commit comments