Skip to content

Commit 2bf26ec

Browse files
committed
Handled unsuspending a renderer completely
1 parent 2f1fa3b commit 2bf26ec

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import * as React from 'react';
1111
import {useContext, useEffect} from 'react';
12-
import {BridgeContext} from '../context';
12+
import {BridgeContext, StoreContext} from '../context';
1313
import {TreeDispatcherContext} from '../Components/TreeContext';
1414
import {useScrollToHostInstance} from '../hooks';
1515
import {
@@ -24,6 +24,7 @@ import type {SuspenseNode} from '../../../frontend/types';
2424

2525
function SuspenseTimelineInput() {
2626
const bridge = useContext(BridgeContext);
27+
const store = useContext(StoreContext);
2728
const treeDispatch = useContext(TreeDispatcherContext);
2829
const suspenseTreeDispatch = useContext(SuspenseTreeDispatcherContext);
2930
const scrollToHostInstance = useScrollToHostInstance();
@@ -106,6 +107,14 @@ function SuspenseTimelineInput() {
106107
number,
107108
Array<SuspenseNode['id']>,
108109
>();
110+
// Unsuspend everything by default.
111+
// We might not encounter every renderer after the milestone e.g.
112+
// if we clicked at the end of the timeline.
113+
// eslint-disable-next-line no-for-of-loops/no-for-of-loops
114+
for (const rendererID of store.rootIDToRendererID.values()) {
115+
suspendedSetByRendererID.set(rendererID, []);
116+
}
117+
109118
// Synchronize timeline index with what is resuspended.
110119
// We suspend everything after the current selection. The root isn't showing
111120
// anything suspended in the root. The step after that should have one less
@@ -114,10 +123,12 @@ function SuspenseTimelineInput() {
114123
for (let i = timelineIndex + 1; i < timeline.length; i++) {
115124
const step = timeline[i];
116125
const {rendererID} = step;
117-
let suspendedSetForRendererID = suspendedSetByRendererID.get(rendererID);
126+
const suspendedSetForRendererID =
127+
suspendedSetByRendererID.get(rendererID);
118128
if (suspendedSetForRendererID === undefined) {
119-
suspendedSetForRendererID = [];
120-
suspendedSetByRendererID.set(rendererID, suspendedSetForRendererID);
129+
throw new Error(
130+
`Should have initialized suspended set for renderer ID "${rendererID}" earlier. This is a bug in React DevTools.`,
131+
);
121132
}
122133
suspendedSetForRendererID.push(step.id);
123134
}

0 commit comments

Comments
 (0)