Skip to content

Commit 15860a2

Browse files
MarkTeetsjasnoominzo-kimyuanjackie1
committed
Added keys to component node hover-over
Co-authored-by: Jasmine Noor <[email protected]> Co-authored-by: Minzo Kim <[email protected]> Co-authored-by: Jackie Yuan <[email protected]>
1 parent b00ab0a commit 15860a2

File tree

4 files changed

+23
-33
lines changed

4 files changed

+23
-33
lines changed

src/app/components/StateRoute/ComponentMap/ComponentMap.tsx

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export default function ComponentMap({
100100
...defaultStyles,
101101
minWidth: 60,
102102
maxWidth: 300,
103-
backgroundColor: 'rgba(0,0,0,0.9)',
103+
backgroundColor: 'rgb(15,15,15)',
104104
color: 'white',
105105
fontSize: '14px',
106106
lineHeight: '18px',
@@ -123,11 +123,6 @@ export default function ComponentMap({
123123
return `${renderTime} ms `;
124124
};
125125

126-
const formatState = (state) => {
127-
if (state === 'stateless') return ['stateless'];
128-
return ['stateful'];
129-
};
130-
131126
// places all nodes into a flat array
132127
const nodeList = [];
133128

@@ -355,21 +350,19 @@ export default function ComponentMap({
355350
}}
356351
>
357352
<div>
358-
<div style={{}}>
359-
{' '}
360-
<strong>{tooltipData.name}</strong>{' '}
353+
<div>
354+
<strong>{tooltipData.name}</strong>
361355
</div>
362-
<div> Render time: {formatRenderTime(tooltipData.componentData.actualDuration)} </div>
363-
<div className='stateTip'>
364-
State: {formatState(tooltipData.state)}
356+
<div className='tooltipKey'>
357+
key: {tooltipData.componentData.key !== null ? tooltipData.componentData.key : 'null'}
365358
</div>
366-
<div style={React.scrollStyle}>
367-
359+
<div> Render time: {formatRenderTime(tooltipData.componentData.actualDuration)} </div>
360+
361+
<div>
368362
<ToolTipDataDisplay
369363
containerName='Props'
370364
dataObj={tooltipData.componentData.props}
371365
/>
372-
373366
<ToolTipDataDisplay
374367
containerName='State'
375368
dataObj={tooltipData.componentData.hooksIndex

src/app/styles/layout/_stateContainer.scss

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -225,18 +225,8 @@
225225
pointer-events:all !important;
226226
}
227227

228-
.stateTip{
229-
margin-top: 3px;
230-
line-height: 1;
231-
height: 100%;
232-
overflow-y: hidden;
233-
max-height: 400px;
234-
}
235-
236-
.stateTip p {
237-
line-height:1;
238-
margin-top: 3px;
239-
margin-bottom: 0px;
228+
.tooltipKey {
229+
margin-bottom: -1px;
240230
}
241231

242232
.historyToolTip{
@@ -253,7 +243,6 @@
253243
margin-bottom: 4px;
254244
padding: 2px;
255245
max-height: 30vh;
256-
// border: 5px solid rgba(0, 0, 0, 0.9);
257246
}
258247

259248
.tooltipData-JSONTree {
@@ -266,7 +255,6 @@
266255
overflow-y: auto;
267256
max-height: 30vh;
268257
scrollbar-color:#919499 #51565e;
269-
270258
}
271259

272260
.tooltipData-JSONTree::-webkit-scrollbar-thumb {
@@ -277,5 +265,3 @@
277265
.tooltipData-JSONTree::-webkit-scrollbar-track{
278266
background:#51565e;
279267
}
280-
281-

src/backend/controllers/createTree.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export default function createTree(currentFiberNode: Fiber): Tree {
5353
memoizedState,
5454
memoizedProps,
5555
elementType,
56+
key,
5657
tag,
5758
actualDuration,
5859
actualStartTime,
@@ -104,6 +105,7 @@ export default function createTree(currentFiberNode: Fiber): Tree {
104105
actualStartTime,
105106
selfBaseDuration,
106107
treeBaseDuration,
108+
key,
107109
props: {},
108110
context: {},
109111
state: null,

src/backend/types/backendTypes.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export interface MsgData {
4444
* @type ComponentData -
4545
* @member actualDuration - The time taken to render the current Fiber node and its descendants during the previous render cycle. This value is used to optimize the rendering of components and to provide performance metrics to developers.
4646
* @member actualStartTime - The time at which the rendering of the current Fiber node started during the previous render cycle.
47+
* @member key - The key a user assigned to the component or null if they didn't assign one
4748
* @member context - {in experiment} - An object contains all context information of the current component
4849
* @member index - {class component only} - The index of the bound setState method stored in `componentActionsRecord`
4950
* @member hooksState - {functional component only} - An object contains all states of the current functional component
@@ -58,6 +59,8 @@ export interface ComponentData {
5859
actualDuration?: number;
5960
/** The time at which the rendering of the current Fiber node started during the previous render cycle. */
6061
actualStartTime?: number;
62+
/**The key a user assigned to the component or null if they didn't assign one */
63+
key: string | null;
6164
/** {in experiment} - An object contains all context information of the current component */
6265
context: {};
6366
/** {class component only} - The index of the bound setState method stored in `componentActionsRecord` */
@@ -154,6 +157,7 @@ export const LegacyHiddenComponent = 24;
154157
* @member actualStartTime - The time at which the rendering of the current Fiber node started during the previous render cycle.
155158
* @member child - Pointer to the first child.
156159
* @member elementType - The type of the current Fiber node's element (e.g. the component function or class, or the DOM element type). For class/functional component, elmementType stores the function definition.
160+
* @member key - The key a user assigned to the component or null if they didn't assign one
157161
* @member memoizedProps - The current props of the component associated with the current Fiber node.
158162
* @member memoizedState - The current state of the component associated with the current Fiber node.
159163
* @member selfBaseDuration - The base duration of the current Fiber node's render phase (excluding the time taken to render its children). This field is only set when the enableProfilerTimer flag is enabled.
@@ -191,10 +195,15 @@ export type Fiber = {
191195
*/
192196
elementType: any;
193197

194-
/** The current props of the component associated with the current Fiber node. */
198+
/**
199+
* Unique key string assigned by the user when making component on null if they didn't assign one
200+
*/
201+
key: string | null;
202+
203+
/** The current state for a functional component associated with the current Fiber node. */
195204
memoizedState: any;
196205

197-
/** The current state of the component associated with the current Fiber node. */
206+
/** The current props of the component associated with the current Fiber node. */
198207
memoizedProps: any;
199208

200209
/**

0 commit comments

Comments
 (0)