Skip to content

Commit 177fe3e

Browse files
committed
Attach updatePriority to root
1 parent cfed715 commit 177fe3e

17 files changed

+265
-50
lines changed

packages/react-reconciler/src/ReactFiberBeginWork.new.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ import {
275275
pushRootMarkerInstance,
276276
TransitionTracingMarker,
277277
} from './ReactFiberTracingMarkerComponent.new';
278+
import {NoEventPriority} from './ReactEventPriorities.new';
278279

279280
const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
280281

@@ -2821,6 +2822,7 @@ function updateDehydratedSuspenseComponent(
28212822
current,
28222823
attemptHydrationAtLane,
28232824
eventTime,
2825+
NoEventPriority,
28242826
);
28252827
} else {
28262828
// We have already tried to ping at a higher priority than we're rendering with

packages/react-reconciler/src/ReactFiberBeginWork.old.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ import {
275275
pushRootMarkerInstance,
276276
TransitionTracingMarker,
277277
} from './ReactFiberTracingMarkerComponent.old';
278+
import {NoEventPriority} from './ReactEventPriorities.old';
278279

279280
const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
280281

@@ -2821,6 +2822,7 @@ function updateDehydratedSuspenseComponent(
28212822
current,
28222823
attemptHydrationAtLane,
28232824
eventTime,
2825+
NoEventPriority,
28242826
);
28252827
} else {
28262828
// We have already tried to ping at a higher priority than we're rendering with

packages/react-reconciler/src/ReactFiberClassComponent.new.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ import {readContext, checkIfContextChanged} from './ReactFiberNewContext.new';
7070
import {
7171
requestEventTime,
7272
requestUpdateLane,
73+
requestUpdateLane_getUpdatePriority,
7374
scheduleUpdateOnFiber,
7475
} from './ReactFiberWorkLoop.new';
7576
import {logForceUpdateScheduled, logStateUpdateScheduled} from './DebugTracing';
@@ -204,6 +205,7 @@ const classComponentUpdater = {
204205
const fiber = getInstance(inst);
205206
const eventTime = requestEventTime();
206207
const lane = requestUpdateLane(fiber);
208+
const updatePriority = requestUpdateLane_getUpdatePriority();
207209

208210
const update = createUpdate(eventTime, lane);
209211
update.payload = payload;
@@ -216,7 +218,7 @@ const classComponentUpdater = {
216218

217219
const root = enqueueUpdate(fiber, update, lane);
218220
if (root !== null) {
219-
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
221+
scheduleUpdateOnFiber(root, fiber, lane, eventTime, updatePriority);
220222
entangleTransitions(root, fiber, lane);
221223
}
222224

@@ -237,6 +239,7 @@ const classComponentUpdater = {
237239
const fiber = getInstance(inst);
238240
const eventTime = requestEventTime();
239241
const lane = requestUpdateLane(fiber);
242+
const updatePriority = requestUpdateLane_getUpdatePriority();
240243

241244
const update = createUpdate(eventTime, lane);
242245
update.tag = ReplaceState;
@@ -251,7 +254,7 @@ const classComponentUpdater = {
251254

252255
const root = enqueueUpdate(fiber, update, lane);
253256
if (root !== null) {
254-
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
257+
scheduleUpdateOnFiber(root, fiber, lane, eventTime, updatePriority);
255258
entangleTransitions(root, fiber, lane);
256259
}
257260

@@ -272,6 +275,7 @@ const classComponentUpdater = {
272275
const fiber = getInstance(inst);
273276
const eventTime = requestEventTime();
274277
const lane = requestUpdateLane(fiber);
278+
const updatePriority = requestUpdateLane_getUpdatePriority();
275279

276280
const update = createUpdate(eventTime, lane);
277281
update.tag = ForceUpdate;
@@ -285,7 +289,7 @@ const classComponentUpdater = {
285289

286290
const root = enqueueUpdate(fiber, update, lane);
287291
if (root !== null) {
288-
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
292+
scheduleUpdateOnFiber(root, fiber, lane, eventTime, updatePriority);
289293
entangleTransitions(root, fiber, lane);
290294
}
291295

packages/react-reconciler/src/ReactFiberClassComponent.old.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ import {readContext, checkIfContextChanged} from './ReactFiberNewContext.old';
7070
import {
7171
requestEventTime,
7272
requestUpdateLane,
73+
requestUpdateLane_getUpdatePriority,
7374
scheduleUpdateOnFiber,
7475
} from './ReactFiberWorkLoop.old';
7576
import {logForceUpdateScheduled, logStateUpdateScheduled} from './DebugTracing';
@@ -204,6 +205,7 @@ const classComponentUpdater = {
204205
const fiber = getInstance(inst);
205206
const eventTime = requestEventTime();
206207
const lane = requestUpdateLane(fiber);
208+
const updatePriority = requestUpdateLane_getUpdatePriority();
207209

208210
const update = createUpdate(eventTime, lane);
209211
update.payload = payload;
@@ -216,7 +218,7 @@ const classComponentUpdater = {
216218

217219
const root = enqueueUpdate(fiber, update, lane);
218220
if (root !== null) {
219-
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
221+
scheduleUpdateOnFiber(root, fiber, lane, eventTime, updatePriority);
220222
entangleTransitions(root, fiber, lane);
221223
}
222224

@@ -237,6 +239,7 @@ const classComponentUpdater = {
237239
const fiber = getInstance(inst);
238240
const eventTime = requestEventTime();
239241
const lane = requestUpdateLane(fiber);
242+
const updatePriority = requestUpdateLane_getUpdatePriority();
240243

241244
const update = createUpdate(eventTime, lane);
242245
update.tag = ReplaceState;
@@ -251,7 +254,7 @@ const classComponentUpdater = {
251254

252255
const root = enqueueUpdate(fiber, update, lane);
253256
if (root !== null) {
254-
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
257+
scheduleUpdateOnFiber(root, fiber, lane, eventTime, updatePriority);
255258
entangleTransitions(root, fiber, lane);
256259
}
257260

@@ -272,6 +275,7 @@ const classComponentUpdater = {
272275
const fiber = getInstance(inst);
273276
const eventTime = requestEventTime();
274277
const lane = requestUpdateLane(fiber);
278+
const updatePriority = requestUpdateLane_getUpdatePriority();
275279

276280
const update = createUpdate(eventTime, lane);
277281
update.tag = ForceUpdate;
@@ -285,7 +289,7 @@ const classComponentUpdater = {
285289

286290
const root = enqueueUpdate(fiber, update, lane);
287291
if (root !== null) {
288-
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
292+
scheduleUpdateOnFiber(root, fiber, lane, eventTime, updatePriority);
289293
entangleTransitions(root, fiber, lane);
290294
}
291295

packages/react-reconciler/src/ReactFiberHooks.new.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ import {
7777
getCurrentUpdatePriority,
7878
setCurrentUpdatePriority,
7979
higherEventPriority,
80+
DiscreteEventPriority,
8081
} from './ReactEventPriorities.new';
8182
import {readContext, checkIfContextChanged} from './ReactFiberNewContext.new';
8283
import {HostRoot, CacheComponent} from './ReactWorkTags';
@@ -104,6 +105,7 @@ import {
104105
requestEventTime,
105106
markSkippedUpdateLanes,
106107
isInvalidExecutionContextForEventFunction,
108+
requestUpdateLane_getUpdatePriority,
107109
} from './ReactFiberWorkLoop.new';
108110

109111
import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber';
@@ -1670,7 +1672,13 @@ function checkIfSnapshotChanged<T>(inst: StoreInstance<T>): boolean {
16701672
function forceStoreRerender(fiber) {
16711673
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
16721674
if (root !== null) {
1673-
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
1675+
scheduleUpdateOnFiber(
1676+
root,
1677+
fiber,
1678+
SyncLane,
1679+
NoTimestamp,
1680+
DiscreteEventPriority,
1681+
);
16741682
}
16751683
}
16761684

@@ -2381,11 +2389,18 @@ function refreshCache<T>(fiber: Fiber, seedKey: ?() => T, seedValue: T) {
23812389
case HostRoot: {
23822390
// Schedule an update on the cache boundary to trigger a refresh.
23832391
const lane = requestUpdateLane(provider);
2392+
const updatePriority = requestUpdateLane_getUpdatePriority();
23842393
const eventTime = requestEventTime();
23852394
const refreshUpdate = createLegacyQueueUpdate(eventTime, lane);
23862395
const root = enqueueLegacyQueueUpdate(provider, refreshUpdate, lane);
23872396
if (root !== null) {
2388-
scheduleUpdateOnFiber(root, provider, lane, eventTime);
2397+
scheduleUpdateOnFiber(
2398+
root,
2399+
provider,
2400+
lane,
2401+
eventTime,
2402+
updatePriority,
2403+
);
23892404
entangleLegacyQueueTransitions(root, provider, lane);
23902405
}
23912406

@@ -2427,6 +2442,7 @@ function dispatchReducerAction<S, A>(
24272442
}
24282443

24292444
const lane = requestUpdateLane(fiber);
2445+
const updatePriority = requestUpdateLane_getUpdatePriority();
24302446

24312447
const update: Update<S, A> = {
24322448
lane,
@@ -2442,7 +2458,7 @@ function dispatchReducerAction<S, A>(
24422458
const root = enqueueConcurrentHookUpdate(fiber, queue, update, lane);
24432459
if (root !== null) {
24442460
const eventTime = requestEventTime();
2445-
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
2461+
scheduleUpdateOnFiber(root, fiber, lane, eventTime, updatePriority);
24462462
entangleTransitionUpdate(root, queue, lane);
24472463
}
24482464
}
@@ -2466,6 +2482,7 @@ function dispatchSetState<S, A>(
24662482
}
24672483

24682484
const lane = requestUpdateLane(fiber);
2485+
const updatePriority = requestUpdateLane_getUpdatePriority();
24692486

24702487
const update: Update<S, A> = {
24712488
lane,
@@ -2524,7 +2541,7 @@ function dispatchSetState<S, A>(
25242541
const root = enqueueConcurrentHookUpdate(fiber, queue, update, lane);
25252542
if (root !== null) {
25262543
const eventTime = requestEventTime();
2527-
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
2544+
scheduleUpdateOnFiber(root, fiber, lane, eventTime, updatePriority);
25282545
entangleTransitionUpdate(root, queue, lane);
25292546
}
25302547
}

packages/react-reconciler/src/ReactFiberHooks.old.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ import {
7777
getCurrentUpdatePriority,
7878
setCurrentUpdatePriority,
7979
higherEventPriority,
80+
DiscreteEventPriority,
8081
} from './ReactEventPriorities.old';
8182
import {readContext, checkIfContextChanged} from './ReactFiberNewContext.old';
8283
import {HostRoot, CacheComponent} from './ReactWorkTags';
@@ -104,6 +105,7 @@ import {
104105
requestEventTime,
105106
markSkippedUpdateLanes,
106107
isInvalidExecutionContextForEventFunction,
108+
requestUpdateLane_getUpdatePriority,
107109
} from './ReactFiberWorkLoop.old';
108110

109111
import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber';
@@ -1670,7 +1672,13 @@ function checkIfSnapshotChanged<T>(inst: StoreInstance<T>): boolean {
16701672
function forceStoreRerender(fiber) {
16711673
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
16721674
if (root !== null) {
1673-
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
1675+
scheduleUpdateOnFiber(
1676+
root,
1677+
fiber,
1678+
SyncLane,
1679+
NoTimestamp,
1680+
DiscreteEventPriority,
1681+
);
16741682
}
16751683
}
16761684

@@ -2381,11 +2389,18 @@ function refreshCache<T>(fiber: Fiber, seedKey: ?() => T, seedValue: T) {
23812389
case HostRoot: {
23822390
// Schedule an update on the cache boundary to trigger a refresh.
23832391
const lane = requestUpdateLane(provider);
2392+
const updatePriority = requestUpdateLane_getUpdatePriority();
23842393
const eventTime = requestEventTime();
23852394
const refreshUpdate = createLegacyQueueUpdate(eventTime, lane);
23862395
const root = enqueueLegacyQueueUpdate(provider, refreshUpdate, lane);
23872396
if (root !== null) {
2388-
scheduleUpdateOnFiber(root, provider, lane, eventTime);
2397+
scheduleUpdateOnFiber(
2398+
root,
2399+
provider,
2400+
lane,
2401+
eventTime,
2402+
updatePriority,
2403+
);
23892404
entangleLegacyQueueTransitions(root, provider, lane);
23902405
}
23912406

@@ -2427,6 +2442,7 @@ function dispatchReducerAction<S, A>(
24272442
}
24282443

24292444
const lane = requestUpdateLane(fiber);
2445+
const updatePriority = requestUpdateLane_getUpdatePriority();
24302446

24312447
const update: Update<S, A> = {
24322448
lane,
@@ -2442,7 +2458,7 @@ function dispatchReducerAction<S, A>(
24422458
const root = enqueueConcurrentHookUpdate(fiber, queue, update, lane);
24432459
if (root !== null) {
24442460
const eventTime = requestEventTime();
2445-
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
2461+
scheduleUpdateOnFiber(root, fiber, lane, eventTime, updatePriority);
24462462
entangleTransitionUpdate(root, queue, lane);
24472463
}
24482464
}
@@ -2466,6 +2482,7 @@ function dispatchSetState<S, A>(
24662482
}
24672483

24682484
const lane = requestUpdateLane(fiber);
2485+
const updatePriority = requestUpdateLane_getUpdatePriority();
24692486

24702487
const update: Update<S, A> = {
24712488
lane,
@@ -2524,7 +2541,7 @@ function dispatchSetState<S, A>(
25242541
const root = enqueueConcurrentHookUpdate(fiber, queue, update, lane);
25252542
if (root !== null) {
25262543
const eventTime = requestEventTime();
2527-
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
2544+
scheduleUpdateOnFiber(root, fiber, lane, eventTime, updatePriority);
25282545
entangleTransitionUpdate(root, queue, lane);
25292546
}
25302547
}

packages/react-reconciler/src/ReactFiberHotReloading.new.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import {
4949
REACT_LAZY_TYPE,
5050
} from 'shared/ReactSymbols';
5151
import {enableFloat} from 'shared/ReactFeatureFlags';
52+
import { DiscreteEventPriority } from './ReactEventPriorities';
5253

5354
let resolveFamily: RefreshHandler | null = null;
5455
let failedBoundaries: WeakSet<Fiber> | null = null;
@@ -314,7 +315,13 @@ function scheduleFibersWithFamiliesRecursively(
314315
if (needsRemount || needsRender) {
315316
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
316317
if (root !== null) {
317-
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
318+
scheduleUpdateOnFiber(
319+
root,
320+
fiber,
321+
SyncLane,
322+
NoTimestamp,
323+
DiscreteEventPriority,
324+
);
318325
}
319326
}
320327
if (child !== null && !needsRemount) {

packages/react-reconciler/src/ReactFiberHotReloading.old.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import {
4949
REACT_LAZY_TYPE,
5050
} from 'shared/ReactSymbols';
5151
import {enableFloat} from 'shared/ReactFeatureFlags';
52+
import { DiscreteEventPriority } from './ReactEventPriorities';
5253

5354
let resolveFamily: RefreshHandler | null = null;
5455
let failedBoundaries: WeakSet<Fiber> | null = null;
@@ -314,7 +315,13 @@ function scheduleFibersWithFamiliesRecursively(
314315
if (needsRemount || needsRender) {
315316
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
316317
if (root !== null) {
317-
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
318+
scheduleUpdateOnFiber(
319+
root,
320+
fiber,
321+
SyncLane,
322+
NoTimestamp,
323+
DiscreteEventPriority,
324+
);
318325
}
319326
}
320327
if (child !== null && !needsRemount) {

packages/react-reconciler/src/ReactFiberLane.new.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import type {Fiber, FiberRoot} from './ReactInternalTypes';
1111
import type {Transition} from './ReactFiberTracingMarkerComponent.new';
1212
import type {ConcurrentUpdate} from './ReactFiberConcurrentUpdates.new';
13+
import type {EventPriority} from './ReactEventPriorities.new';
1314

1415
// TODO: Ideally these types would be opaque but that doesn't work well with
1516
// our reconciler fork infra, since these leak into non-reconciler packages.
@@ -588,9 +589,11 @@ export function markRootUpdated(
588589
root: FiberRoot,
589590
updateLane: Lane,
590591
eventTime: number,
592+
updatePriority: EventPriority,
591593
) {
592594
root.pendingLanes |= updateLane;
593595

596+
root.updatePriority = updatePriority;
594597
// If there are any suspended transitions, it's possible this new update
595598
// could unblock them. Clear the suspended lanes so that we can try rendering
596599
// them again.

0 commit comments

Comments
 (0)