Skip to content

Commit b58a8e3

Browse files
authored
[DevTools] Handle mount of disconnected Suspense boundaries (#34208)
1 parent 42b1b33 commit b58a8e3

File tree

1 file changed

+21
-11
lines changed
  • packages/react-devtools-shared/src/devtools

1 file changed

+21
-11
lines changed

packages/react-devtools-shared/src/devtools/store.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,14 @@ export default class Store extends EventEmitter<{
12061206
}
12071207
set.add(id);
12081208
}
1209+
1210+
const suspense = this._idToSuspense.get(id);
1211+
if (suspense !== undefined) {
1212+
// We're reconnecting a node.
1213+
if (suspense.name === null) {
1214+
suspense.name = this._guessSuspenseName(element);
1215+
}
1216+
}
12091217
}
12101218
break;
12111219
}
@@ -1432,21 +1440,12 @@ export default class Store extends EventEmitter<{
14321440

14331441
const element = this._idToElement.get(id);
14341442
if (element === undefined) {
1435-
this._throwAndEmitError(
1436-
Error(
1437-
`Cannot add suspense node "${id}" because no matching element was found in the Store.`,
1438-
),
1439-
);
1443+
// This element isn't connected yet.
14401444
} else {
14411445
if (name === null) {
14421446
// The boundary isn't explicitly named.
14431447
// Pick a sensible default.
1444-
// TODO: Use key
1445-
const owner = this._idToElement.get(element.ownerID);
1446-
if (owner !== undefined) {
1447-
// TODO: This is clowny
1448-
name = `${owner.displayName || 'Unknown'}>?`;
1449-
}
1448+
name = this._guessSuspenseName(element);
14501449
}
14511450
}
14521451

@@ -1936,4 +1935,15 @@ export default class Store extends EventEmitter<{
19361935
// and for unit testing the Store itself.
19371936
throw error;
19381937
}
1938+
1939+
_guessSuspenseName(element: Element): string | null {
1940+
// TODO: Use key
1941+
const owner = this._idToElement.get(element.ownerID);
1942+
if (owner !== undefined) {
1943+
// TODO: This is clowny
1944+
return `${owner.displayName || 'Unknown'}>?`;
1945+
}
1946+
1947+
return null;
1948+
}
19391949
}

0 commit comments

Comments
 (0)