[DevTools] Dedicated empty state for roots that aren't suspended by anything#507
Conversation
Greptile OverviewGreptile Summaryadded dedicated empty state message "Nothing suspended the initial paint" for root elements that have no suspenders in the DevTools Suspense tab Key changes:
Purpose: Note from previous review thread: Confidence Score: 2/5
Important Files Changed
|
| // For roots, show an empty state since there's nothing else to show for | ||
| // these elements. | ||
| // This can happen for older versions of React without Suspense, older versions | ||
| // of React with less sources for Suspense, or simple UIs that don't have any suspenders. | ||
| if (inspectedElement.type === ElementTypeRoot) { | ||
| return ( | ||
| <div> | ||
| <div className={styles.HeaderRow}> | ||
| <div className={`${styles.Header} ${styles.Empty}`}> | ||
| Nothing suspended the initial paint. | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
| } |
There was a problem hiding this comment.
when suspendedBy is null/empty, not suspended, and not a root element, the function continues without returning, then tries to access suspendedBy.length at line 510
| // For roots, show an empty state since there's nothing else to show for | |
| // these elements. | |
| // This can happen for older versions of React without Suspense, older versions | |
| // of React with less sources for Suspense, or simple UIs that don't have any suspenders. | |
| if (inspectedElement.type === ElementTypeRoot) { | |
| return ( | |
| <div> | |
| <div className={styles.HeaderRow}> | |
| <div className={`${styles.Header} ${styles.Empty}`}> | |
| Nothing suspended the initial paint. | |
| </div> | |
| </div> | |
| </div> | |
| ); | |
| } | |
| } | |
| // For roots, show an empty state since there's nothing else to show for | |
| // these elements. | |
| // This can happen for older versions of React without Suspense, older versions | |
| // of React with less sources for Suspense, or simple UIs that don't have any suspenders. | |
| if (inspectedElement.type === ElementTypeRoot) { | |
| return ( | |
| <div> | |
| <div className={styles.HeaderRow}> | |
| <div className={`${styles.Header} ${styles.Empty}`}> | |
| Nothing suspended the initial paint. | |
| </div> | |
| </div> | |
| </div> | |
| ); | |
| } | |
| return null; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/react-devtools-shared/src/devtools/views/Components/InspectedElementSuspendedBy.js
Line: 481:496
Comment:
when `suspendedBy` is null/empty, not suspended, and not a root element, the function continues without returning, then tries to access `suspendedBy.length` at line 510
```suggestion
// For roots, show an empty state since there's nothing else to show for
// these elements.
// This can happen for older versions of React without Suspense, older versions
// of React with less sources for Suspense, or simple UIs that don't have any suspenders.
if (inspectedElement.type === ElementTypeRoot) {
return (
<div>
<div className={styles.HeaderRow}>
<div className={`${styles.Header} ${styles.Empty}`}>
Nothing suspended the initial paint.
</div>
</div>
</div>
);
}
return null;
```
How can I resolve this? If you propose a fix, please make it concise.7ebf943 to
c30e925
Compare
| </div> | ||
| ); | ||
| } | ||
| } |
There was a problem hiding this comment.
missing return null for non-root elements - when suspendedBy is null/empty and element is not suspended and not a root, the code continues to line 510 where suspendedBy.length will throw TypeError
before this PR, line 480 had return null that handled this case
| } | |
| } | |
| return null; | |
| } |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/react-devtools-shared/src/devtools/views/Components/InspectedElementSuspendedBy.js
Line: 496:496
Comment:
missing `return null` for non-root elements - when `suspendedBy` is null/empty and element is not suspended and not a root, the code continues to line 510 where `suspendedBy.length` will throw `TypeError`
before this PR, line 480 had `return null` that handled this case
```suggestion
}
return null;
}
```
How can I resolve this? If you propose a fix, please make it concise.|
Upstream PR was closed or merged. Code is synced via branch mirror. |
Mirror of facebook/react#35769
Original author: eps1lon
Summary
Stacked on react/react#35768
For roots without any suspenders, the inspected element pane is completely empty. For older versions of React without Suspense, older versions of React with less sources for Suspense, or simple UIs that don't have any suspenders this can look like something isn't working. You're mostly inspecting the root in the Suspense tab so we need something to show.
How did you test this change?