Skip to content

Commit ed18b6b

Browse files
committed
Synchronize resuspending with the current timeline index
1 parent 3e1247b commit ed18b6b

1 file changed

Lines changed: 20 additions & 19 deletions

File tree

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

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -101,26 +101,7 @@ function SuspenseTimelineInput() {
101101
}
102102

103103
function handleChange(event: SyntheticEvent) {
104-
if (rootID === null) {
105-
return;
106-
}
107-
const rendererID = store.getRendererIDForElement(rootID);
108-
if (rendererID === null) {
109-
console.error(
110-
`No renderer ID found for root element ${rootID} in suspense timeline.`,
111-
);
112-
return;
113-
}
114-
115104
const pendingTimelineIndex = +event.currentTarget.value;
116-
const suspendedSet = timeline.slice(pendingTimelineIndex);
117-
118-
bridge.send('overrideSuspenseMilestone', {
119-
rendererID,
120-
rootID,
121-
suspendedSet,
122-
});
123-
124105
switchSuspenseNode(pendingTimelineIndex);
125106
}
126107

@@ -189,6 +170,26 @@ function SuspenseTimelineInput() {
189170
});
190171
}
191172

173+
useEffect(() => {
174+
// Synchronize timeline index with what is resuspended.
175+
if (rootID === null) {
176+
return;
177+
}
178+
const rendererID = store.getRendererIDForElement(rootID);
179+
if (rendererID === null) {
180+
console.error(
181+
`No renderer ID found for root element ${rootID} in suspense timeline.`,
182+
);
183+
return;
184+
}
185+
const suspendedSet = timeline.slice(timelineIndex);
186+
bridge.send('overrideSuspenseMilestone', {
187+
rendererID,
188+
rootID,
189+
suspendedSet,
190+
});
191+
}, [rootID, store, bridge, timeline, timelineIndex]);
192+
192193
useEffect(() => {
193194
if (!playing) {
194195
return undefined;

0 commit comments

Comments
 (0)