Skip to content

Commit 472775b

Browse files
committed
Use the environment of the timeline step as a label or "Suspense" if no environment
1 parent 09a2524 commit 472775b

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseScrubber.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
* @flow
88
*/
99

10+
import type {SuspenseTimelineStep} from 'react-devtools-shared/src/frontend/types';
11+
1012
import typeof {SyntheticEvent} from 'react-dom-bindings/src/events/SyntheticEvent';
1113

1214
import * as React from 'react';
@@ -19,6 +21,7 @@ import Tooltip from '../Components/reach-ui/tooltip';
1921
export default function SuspenseScrubber({
2022
min,
2123
max,
24+
timeline,
2225
value,
2326
highlight,
2427
onBlur,
@@ -29,6 +32,7 @@ export default function SuspenseScrubber({
2932
}: {
3033
min: number,
3134
max: number,
35+
timeline: $ReadOnlyArray<SuspenseTimelineStep>,
3236
value: number,
3337
highlight: number,
3438
onBlur?: () => void,
@@ -54,17 +58,18 @@ export default function SuspenseScrubber({
5458
}
5559
const steps = [];
5660
for (let index = min; index <= max; index++) {
61+
const environment = timeline[index].environment;
62+
const label =
63+
index === min
64+
? // The first step in the timeline is always a Transition (Initial Paint).
65+
'Initial Paint' +
66+
(environment === null ? '' : ' (' + environment + ')')
67+
: // TODO: Consider adding the name of this specific boundary if this step has only one.
68+
environment === null
69+
? 'Suspense'
70+
: environment;
5771
steps.push(
58-
<Tooltip
59-
key={index}
60-
label={
61-
index === min
62-
? // The first step in the timeline is always a Transition (Initial Paint).
63-
// TODO: Support multiple environments.
64-
'Initial Paint'
65-
: // TODO: Consider adding the name of this specific boundary if this step has only one.
66-
'Suspense'
67-
}>
72+
<Tooltip key={index} label={label}>
6873
<div
6974
className={
7075
styles.SuspenseScrubberStep +

packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseTimeline.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ function SuspenseTimelineInput() {
173173
<SuspenseScrubber
174174
min={min}
175175
max={max}
176+
timeline={timeline}
176177
value={timelineIndex}
177178
highlight={hoveredTimelineIndex}
178179
onChange={handleChange}

0 commit comments

Comments
 (0)