mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
[DevTools] Avoid uncached Promise when symbolicating sources in environments without file fetching (#34224)
This commit is contained in:
committed by
GitHub
parent
b58a8e3c40
commit
01ed0e9642
@@ -34,6 +34,8 @@ export type Props = {};
|
||||
|
||||
// TODO Make edits and deletes also use transition API!
|
||||
|
||||
const noSourcePromise = Promise.resolve(null);
|
||||
|
||||
export default function InspectedElementWrapper(_: Props): React.Node {
|
||||
const {inspectedElementID} = useContext(TreeStateContext);
|
||||
const bridge = useContext(BridgeContext);
|
||||
@@ -59,11 +61,11 @@ export default function InspectedElementWrapper(_: Props): React.Node {
|
||||
? inspectedElement.stack[0]
|
||||
: null;
|
||||
|
||||
const symbolicatedSourcePromise: null | Promise<ReactFunctionLocation | null> =
|
||||
const symbolicatedSourcePromise: Promise<ReactFunctionLocation | null> =
|
||||
React.useMemo(() => {
|
||||
if (fetchFileWithCaching == null) return Promise.resolve(null);
|
||||
if (fetchFileWithCaching == null) return noSourcePromise;
|
||||
|
||||
if (source == null) return Promise.resolve(null);
|
||||
if (source == null) return noSourcePromise;
|
||||
|
||||
const [, sourceURL, line, column] = source;
|
||||
return symbolicateSourceWithCache(
|
||||
@@ -291,7 +293,7 @@ export default function InspectedElementWrapper(_: Props): React.Node {
|
||||
<div className={styles.Loading}>Loading...</div>
|
||||
)}
|
||||
|
||||
{inspectedElement !== null && symbolicatedSourcePromise != null && (
|
||||
{inspectedElement !== null && (
|
||||
<InspectedElementView
|
||||
element={element}
|
||||
hookNames={hookNames}
|
||||
|
||||
Reference in New Issue
Block a user