Skip to content

Commit 040f828

Browse files
authored
Follow through all the phases when an error happens during snapshotting (#32803)
This can happen for example if you have duplicate names in the "old" state. This errors the transition before the updateCallback is invoked so we haven't yet applied mutations etc. This runs through those phases after the error to get us back to a consistent state.
1 parent 450f8df commit 040f828

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

+13-1
Original file line numberDiff line numberDiff line change
@@ -1802,6 +1802,12 @@ export function startViewTransition(
18021802
}
18031803
} finally {
18041804
// Continue the reset of the work.
1805+
// If the error happened in the snapshot phase before the update callback
1806+
// was invoked, then we need to first finish the mutation and layout phases.
1807+
// If they're already invoked it's still safe to call them due the status check.
1808+
mutationCallback();
1809+
layoutCallback();
1810+
// Skip afterMutationCallback() since we're not animating.
18051811
spawnedWorkCallback();
18061812
}
18071813
};
@@ -2137,7 +2143,13 @@ export function startGestureTransition(
21372143
}
21382144
} finally {
21392145
// Continue the reset of the work.
2140-
readyCallback();
2146+
// If the error happened in the snapshot phase before the update callback
2147+
// was invoked, then we need to first finish the mutation and layout phases.
2148+
// If they're already invoked it's still safe to call them due the status check.
2149+
mutationCallback();
2150+
// Skip readyCallback() and go straight to animateCallbck() since we're not animating.
2151+
// animateCallback() is still required to restore states.
2152+
animateCallback();
21412153
}
21422154
};
21432155
transition.ready.then(readyForAnimations, handleError);

0 commit comments

Comments
 (0)