Skip to content

Commit 60ac750

Browse files
committed
Customize the suspended commit message based on reason
1 parent 6d80e59 commit 60ac750

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5965,6 +5965,7 @@ export opaque type SuspendedState = {
59655965
imgBytes: number, // number of bytes we estimate needing to download
59665966
suspenseyImages: Array<HTMLImageElement>, // instances of suspensey images (whether loaded or not)
59675967
waitingForImages: boolean, // false when we're no longer blocking on images
5968+
waitingForViewTransition: boolean,
59685969
unsuspend: null | (() => void),
59695970
};
59705971

@@ -5976,6 +5977,7 @@ export function startSuspendingCommit(): SuspendedState {
59765977
imgBytes: 0,
59775978
suspenseyImages: [],
59785979
waitingForImages: true,
5980+
waitingForViewTransition: false,
59795981
// We use a noop function when we begin suspending because if possible we want the
59805982
// waitfor step to finish synchronously. If it doesn't we'll return a function to
59815983
// provide the actual unsuspend function and that will get completed when the count
@@ -6123,6 +6125,7 @@ export function suspendOnActiveViewTransition(
61236125
return;
61246126
}
61256127
state.count++;
6128+
state.waitingForViewTransition = true;
61266129
const ping = onUnsuspend.bind(state);
61276130
activeViewTransition.finished.then(ping, ping);
61286131
}
@@ -6210,7 +6213,22 @@ export function getSuspendedCommitReason(
62106213
state: SuspendedState,
62116214
rootContainer: Container,
62126215
): null | string {
6213-
return 'Suspended on CSS or Images';
6216+
if (state.waitingForViewTransition) {
6217+
return 'Waiting for the previous Animation';
6218+
}
6219+
if (state.count > 0) {
6220+
if (state.imgCount > 0) {
6221+
return 'Suspended on CSS and Images';
6222+
}
6223+
return 'Suspended on CSS';
6224+
}
6225+
if (state.imgCount === 1) {
6226+
return 'Suspended on an Image';
6227+
}
6228+
if (state.imgCount > 0) {
6229+
return 'Suspended on Images';
6230+
}
6231+
return null;
62146232
}
62156233

62166234
function checkIfFullyUnsuspended(state: SuspendedState) {

0 commit comments

Comments
 (0)