Skip to content

Commit 243b27b

Browse files
committed
Show a notice
1 parent 6b18234 commit 243b27b

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

packages/react-devtools-shared/src/devtools/views/Components/InspectedElementSharedStyles.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@
5252
min-width: 1rem;
5353
}
5454

55+
.InfoRow {
56+
border-top: 1px solid var(--color-border);
57+
padding: 0.5rem 1rem;
58+
}
59+
60+
.InfoRow:last-child {
61+
margin-bottom: -0.25rem;
62+
}
63+
5564
.CollapsableRow {
5665
border-top: 1px solid var(--color-border);
5766
}

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

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ import type {
2727
} from 'react-devtools-shared/src/frontend/types';
2828
import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
2929

30+
import {
31+
UNKNOWN_SUSPENDERS_NONE,
32+
UNKNOWN_SUSPENDERS_REASON_PRODUCTION,
33+
UNKNOWN_SUSPENDERS_REASON_OLD_VERSION,
34+
UNKNOWN_SUSPENDERS_REASON_THROWN_PROMISE,
35+
} from '../../../constants';
36+
3037
type RowProps = {
3138
bridge: FrontendBridge,
3239
element: Element,
@@ -295,7 +302,10 @@ export default function InspectedElementSuspendedBy({
295302
const {suspendedBy, suspendedByRange} = inspectedElement;
296303

297304
// Skip the section if nothing suspended this component.
298-
if (suspendedBy == null || suspendedBy.length === 0) {
305+
if (
306+
(suspendedBy == null || suspendedBy.length === 0) &&
307+
inspectedElement.unknownSuspenders === UNKNOWN_SUSPENDERS_NONE
308+
) {
299309
return null;
300310
}
301311

@@ -327,9 +337,41 @@ export default function InspectedElementSuspendedBy({
327337
minTime = maxTime - 25;
328338
}
329339

330-
const sortedSuspendedBy = suspendedBy.slice(0);
340+
const sortedSuspendedBy = suspendedBy === null ? [] : suspendedBy.slice(0);
331341
sortedSuspendedBy.sort(compareTime);
332342

343+
let unknownSuspenders = null;
344+
switch (inspectedElement.unknownSuspenders) {
345+
case UNKNOWN_SUSPENDERS_REASON_PRODUCTION:
346+
unknownSuspenders = (
347+
<div className={styles.InfoRow}>
348+
Something suspended but we don't know the exact reason in production
349+
builds of React. Test this in development mode to see exactly what
350+
might suspend.
351+
</div>
352+
);
353+
break;
354+
case UNKNOWN_SUSPENDERS_REASON_OLD_VERSION:
355+
unknownSuspenders = (
356+
<div className={styles.InfoRow}>
357+
Something suspended but we don't track all the necessary information
358+
in older versions of React. Upgrade to the latest version of React to
359+
see exactly what might suspend.
360+
</div>
361+
);
362+
break;
363+
case UNKNOWN_SUSPENDERS_REASON_THROWN_PROMISE:
364+
unknownSuspenders = (
365+
<div className={styles.InfoRow}>
366+
Something threw a Promise to suspend this boundary. It's likely an
367+
outdated version of a library that doesn't yet fully take advantage of
368+
use(). Upgrade your data fetching library to see exactly what might
369+
suspend.
370+
</div>
371+
);
372+
break;
373+
}
374+
333375
return (
334376
<div>
335377
<div className={styles.HeaderRow}>
@@ -351,6 +393,7 @@ export default function InspectedElementSuspendedBy({
351393
maxTime={maxTime}
352394
/>
353395
))}
396+
{unknownSuspenders}
354397
</div>
355398
);
356399
}

0 commit comments

Comments
 (0)