Skip to content

Commit fd23be0

Browse files
committed
Always flush Default priority in the microtask if a Transition was scheduled too
1 parent 62d3f36 commit fd23be0

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

packages/react-reconciler/src/ReactFiberRootScheduler.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
NoLane,
2727
NoLanes,
2828
SyncLane,
29+
DefaultLane,
2930
getHighestPriorityLane,
3031
getNextLanes,
3132
includesSyncLane,
@@ -261,6 +262,13 @@ function processRootScheduleInMicrotask() {
261262
// render it synchronously anyway. We do this during a popstate event to
262263
// preserve the scroll position of the previous page.
263264
syncTransitionLanes = currentEventTransitionLane;
265+
} else if (enableDefaultTransitionIndicator) {
266+
// If we have a Transition scheduled by this event it might be paired
267+
// with Default lane scheduled loading indicators. To unbatch it from
268+
// other events later on, flush it early to determine whether it
269+
// rendered an indicator. This ensures that setState in default priority
270+
// event doesn't trigger onDefaultTransitionIndicator.
271+
syncTransitionLanes = DefaultLane;
264272
}
265273
}
266274

packages/react-reconciler/src/__tests__/ReactDefaultTransitionIndicator-test.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,7 @@ describe('ReactDefaultTransitionIndicator', () => {
109109
expect(root).toMatchRenderedOutput(<div>Hi</div>);
110110

111111
await act(() => {
112-
// TODO: This should not require a discrete update ideally but work for default too.
113-
ReactNoop.discreteUpdates(() => {
114-
update('Loading...');
115-
});
112+
update('Loading...');
116113
React.startTransition(() => {
117114
update('');
118115
root.render(<App>{promiseB}</App>);

0 commit comments

Comments
 (0)