Skip to content

Commit 01ed0e9

Browse files
authored
[DevTools] Avoid uncached Promise when symbolicating sources in environments without file fetching (#34224)
1 parent b58a8e3 commit 01ed0e9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/react-devtools-shared/src/devtools/views/Components/InspectedElement.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ export type Props = {};
3434

3535
// TODO Make edits and deletes also use transition API!
3636

37+
const noSourcePromise = Promise.resolve(null);
38+
3739
export default function InspectedElementWrapper(_: Props): React.Node {
3840
const {inspectedElementID} = useContext(TreeStateContext);
3941
const bridge = useContext(BridgeContext);
@@ -59,11 +61,11 @@ export default function InspectedElementWrapper(_: Props): React.Node {
5961
? inspectedElement.stack[0]
6062
: null;
6163

62-
const symbolicatedSourcePromise: null | Promise<ReactFunctionLocation | null> =
64+
const symbolicatedSourcePromise: Promise<ReactFunctionLocation | null> =
6365
React.useMemo(() => {
64-
if (fetchFileWithCaching == null) return Promise.resolve(null);
66+
if (fetchFileWithCaching == null) return noSourcePromise;
6567

66-
if (source == null) return Promise.resolve(null);
68+
if (source == null) return noSourcePromise;
6769

6870
const [, sourceURL, line, column] = source;
6971
return symbolicateSourceWithCache(
@@ -291,7 +293,7 @@ export default function InspectedElementWrapper(_: Props): React.Node {
291293
<div className={styles.Loading}>Loading...</div>
292294
)}
293295

294-
{inspectedElement !== null && symbolicatedSourcePromise != null && (
296+
{inspectedElement !== null && (
295297
<InspectedElementView
296298
element={element}
297299
hookNames={hookNames}

0 commit comments

Comments
 (0)