Skip to content

[Fiber] Always flush Default priority in the microtask if a Transition was scheduled #33186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/react-reconciler/src/ReactFiberRootScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
NoLane,
NoLanes,
SyncLane,
DefaultLane,
getHighestPriorityLane,
getNextLanes,
includesSyncLane,
Expand Down Expand Up @@ -261,6 +262,13 @@ function processRootScheduleInMicrotask() {
// render it synchronously anyway. We do this during a popstate event to
// preserve the scroll position of the previous page.
syncTransitionLanes = currentEventTransitionLane;
} else if (enableDefaultTransitionIndicator) {
// If we have a Transition scheduled by this event it might be paired
// with Default lane scheduled loading indicators. To unbatch it from
// other events later on, flush it early to determine whether it
// rendered an indicator. This ensures that setState in default priority
// event doesn't trigger onDefaultTransitionIndicator.
syncTransitionLanes = DefaultLane;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ describe('ReactDefaultTransitionIndicator', () => {
expect(root).toMatchRenderedOutput(<div>Hi</div>);

await act(() => {
// TODO: This should not require a discrete update ideally but work for default too.
ReactNoop.discreteUpdates(() => {
update('Loading...');
});
update('Loading...');
React.startTransition(() => {
update('');
root.render(<App>{promiseB}</App>);
Expand Down
Loading