Skip to content

Commit 66f09bd

Browse files
authored
[DevTools] Sort "Suspended By" view by the start time (facebook#34105)
or end time if they have the same start time. <img width="517" height="411" alt="Screenshot 2025-08-04 at 4 00 23 PM" src="https://github.com/user-attachments/assets/b99be67b-5727-4e24-98c0-ee064fb21e2f" /> They would typically appear in this order naturally but not always. Especially in Suspense boundaries where the order can also be depended on when the components are discovered.
1 parent 0825d01 commit 66f09bd

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,15 @@ type Props = {
228228
store: Store,
229229
};
230230

231+
function compareTime(a: SerializedAsyncInfo, b: SerializedAsyncInfo): number {
232+
const ioA = a.awaited;
233+
const ioB = b.awaited;
234+
if (ioA.start === ioB.start) {
235+
return ioA.end - ioB.end;
236+
}
237+
return ioA.start - ioB.start;
238+
}
239+
231240
export default function InspectedElementSuspendedBy({
232241
bridge,
233242
element,
@@ -264,6 +273,9 @@ export default function InspectedElementSuspendedBy({
264273
minTime = maxTime - 25;
265274
}
266275

276+
const sortedSuspendedBy = suspendedBy.slice(0);
277+
sortedSuspendedBy.sort(compareTime);
278+
267279
return (
268280
<div>
269281
<div className={styles.HeaderRow}>
@@ -272,7 +284,7 @@ export default function InspectedElementSuspendedBy({
272284
<ButtonIcon type="copy" />
273285
</Button>
274286
</div>
275-
{suspendedBy.map((asyncInfo, index) => (
287+
{sortedSuspendedBy.map((asyncInfo, index) => (
276288
<SuspendedByRow
277289
key={index}
278290
index={index}

0 commit comments

Comments
 (0)