[DevTools] Avoid uncached Promise when symbolicating sources in environments without file fetching (#34224)
Sebastian "Sebbie" Silbermann committed
Aug 18, 2025 at 12:46 UTC
01ed0e96427328780c8da4caa93377eb9746ff08
1 file changed
+6
-4
packages/react-devtools-shared/src/devtools/views/Components/InspectedElement.js
+6
-4
@@ -34,6 +34,8 @@ export type Props = {};
34
35
// TODO Make edits and deletes also use transition API!
36
37
+const noSourcePromise = Promise.resolve(null);
38
+
39
export default function InspectedElementWrapper(_: Props): React.Node {
40
const {inspectedElementID} = useContext(TreeStateContext);
41
const bridge = useContext(BridgeContext);
@@ -59,11 +61,11 @@ export default function InspectedElementWrapper(_: Props): React.Node {
61
? inspectedElement.stack[0]
62
: null;
63
62
- const symbolicatedSourcePromise: null | Promise<ReactFunctionLocation | null> =
64
+ const symbolicatedSourcePromise: Promise<ReactFunctionLocation | null> =
65
React.useMemo(() => {
64
- if (fetchFileWithCaching == null) return Promise.resolve(null);
66
+ if (fetchFileWithCaching == null) return noSourcePromise;
67
66
- if (source == null) return Promise.resolve(null);
68
+ if (source == null) return noSourcePromise;
69
70
const [, sourceURL, line, column] = source;
71
return symbolicateSourceWithCache(
@@ -291,7 +293,7 @@ export default function InspectedElementWrapper(_: Props): React.Node {
293
<div className={styles.Loading}>Loading...</div>
294
)}
295
294
- {inspectedElement !== null && symbolicatedSourcePromise != null && (
296
+ {inspectedElement !== null && (
297
<InspectedElementView
298
element={element}
299
hookNames={hookNames}