mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Attach updatePriority to root
This commit is contained in:
@@ -275,6 +275,7 @@ import {
|
||||
pushRootMarkerInstance,
|
||||
TransitionTracingMarker,
|
||||
} from './ReactFiberTracingMarkerComponent.new';
|
||||
import {NoEventPriority} from './ReactEventPriorities.new';
|
||||
|
||||
const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
||||
|
||||
@@ -2821,6 +2822,7 @@ function updateDehydratedSuspenseComponent(
|
||||
current,
|
||||
attemptHydrationAtLane,
|
||||
eventTime,
|
||||
NoEventPriority,
|
||||
);
|
||||
} else {
|
||||
// We have already tried to ping at a higher priority than we're rendering with
|
||||
|
||||
@@ -275,6 +275,7 @@ import {
|
||||
pushRootMarkerInstance,
|
||||
TransitionTracingMarker,
|
||||
} from './ReactFiberTracingMarkerComponent.old';
|
||||
import {NoEventPriority} from './ReactEventPriorities.old';
|
||||
|
||||
const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
||||
|
||||
@@ -2821,6 +2822,7 @@ function updateDehydratedSuspenseComponent(
|
||||
current,
|
||||
attemptHydrationAtLane,
|
||||
eventTime,
|
||||
NoEventPriority,
|
||||
);
|
||||
} else {
|
||||
// We have already tried to ping at a higher priority than we're rendering with
|
||||
|
||||
@@ -70,6 +70,7 @@ import {readContext, checkIfContextChanged} from './ReactFiberNewContext.new';
|
||||
import {
|
||||
requestEventTime,
|
||||
requestUpdateLane,
|
||||
requestUpdateLane_getUpdatePriority,
|
||||
scheduleUpdateOnFiber,
|
||||
} from './ReactFiberWorkLoop.new';
|
||||
import {logForceUpdateScheduled, logStateUpdateScheduled} from './DebugTracing';
|
||||
@@ -204,6 +205,7 @@ const classComponentUpdater = {
|
||||
const fiber = getInstance(inst);
|
||||
const eventTime = requestEventTime();
|
||||
const lane = requestUpdateLane(fiber);
|
||||
const updatePriority = requestUpdateLane_getUpdatePriority();
|
||||
|
||||
const update = createUpdate(eventTime, lane);
|
||||
update.payload = payload;
|
||||
@@ -216,7 +218,7 @@ const classComponentUpdater = {
|
||||
|
||||
const root = enqueueUpdate(fiber, update, lane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime, updatePriority);
|
||||
entangleTransitions(root, fiber, lane);
|
||||
}
|
||||
|
||||
@@ -237,6 +239,7 @@ const classComponentUpdater = {
|
||||
const fiber = getInstance(inst);
|
||||
const eventTime = requestEventTime();
|
||||
const lane = requestUpdateLane(fiber);
|
||||
const updatePriority = requestUpdateLane_getUpdatePriority();
|
||||
|
||||
const update = createUpdate(eventTime, lane);
|
||||
update.tag = ReplaceState;
|
||||
@@ -251,7 +254,7 @@ const classComponentUpdater = {
|
||||
|
||||
const root = enqueueUpdate(fiber, update, lane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime, updatePriority);
|
||||
entangleTransitions(root, fiber, lane);
|
||||
}
|
||||
|
||||
@@ -272,6 +275,7 @@ const classComponentUpdater = {
|
||||
const fiber = getInstance(inst);
|
||||
const eventTime = requestEventTime();
|
||||
const lane = requestUpdateLane(fiber);
|
||||
const updatePriority = requestUpdateLane_getUpdatePriority();
|
||||
|
||||
const update = createUpdate(eventTime, lane);
|
||||
update.tag = ForceUpdate;
|
||||
@@ -285,7 +289,7 @@ const classComponentUpdater = {
|
||||
|
||||
const root = enqueueUpdate(fiber, update, lane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime, updatePriority);
|
||||
entangleTransitions(root, fiber, lane);
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ import {readContext, checkIfContextChanged} from './ReactFiberNewContext.old';
|
||||
import {
|
||||
requestEventTime,
|
||||
requestUpdateLane,
|
||||
requestUpdateLane_getUpdatePriority,
|
||||
scheduleUpdateOnFiber,
|
||||
} from './ReactFiberWorkLoop.old';
|
||||
import {logForceUpdateScheduled, logStateUpdateScheduled} from './DebugTracing';
|
||||
@@ -204,6 +205,7 @@ const classComponentUpdater = {
|
||||
const fiber = getInstance(inst);
|
||||
const eventTime = requestEventTime();
|
||||
const lane = requestUpdateLane(fiber);
|
||||
const updatePriority = requestUpdateLane_getUpdatePriority();
|
||||
|
||||
const update = createUpdate(eventTime, lane);
|
||||
update.payload = payload;
|
||||
@@ -216,7 +218,7 @@ const classComponentUpdater = {
|
||||
|
||||
const root = enqueueUpdate(fiber, update, lane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime, updatePriority);
|
||||
entangleTransitions(root, fiber, lane);
|
||||
}
|
||||
|
||||
@@ -237,6 +239,7 @@ const classComponentUpdater = {
|
||||
const fiber = getInstance(inst);
|
||||
const eventTime = requestEventTime();
|
||||
const lane = requestUpdateLane(fiber);
|
||||
const updatePriority = requestUpdateLane_getUpdatePriority();
|
||||
|
||||
const update = createUpdate(eventTime, lane);
|
||||
update.tag = ReplaceState;
|
||||
@@ -251,7 +254,7 @@ const classComponentUpdater = {
|
||||
|
||||
const root = enqueueUpdate(fiber, update, lane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime, updatePriority);
|
||||
entangleTransitions(root, fiber, lane);
|
||||
}
|
||||
|
||||
@@ -272,6 +275,7 @@ const classComponentUpdater = {
|
||||
const fiber = getInstance(inst);
|
||||
const eventTime = requestEventTime();
|
||||
const lane = requestUpdateLane(fiber);
|
||||
const updatePriority = requestUpdateLane_getUpdatePriority();
|
||||
|
||||
const update = createUpdate(eventTime, lane);
|
||||
update.tag = ForceUpdate;
|
||||
@@ -285,7 +289,7 @@ const classComponentUpdater = {
|
||||
|
||||
const root = enqueueUpdate(fiber, update, lane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime, updatePriority);
|
||||
entangleTransitions(root, fiber, lane);
|
||||
}
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@ import {
|
||||
getCurrentUpdatePriority,
|
||||
setCurrentUpdatePriority,
|
||||
higherEventPriority,
|
||||
DiscreteEventPriority,
|
||||
} from './ReactEventPriorities.new';
|
||||
import {readContext, checkIfContextChanged} from './ReactFiberNewContext.new';
|
||||
import {HostRoot, CacheComponent} from './ReactWorkTags';
|
||||
@@ -104,6 +105,7 @@ import {
|
||||
requestEventTime,
|
||||
markSkippedUpdateLanes,
|
||||
isInvalidExecutionContextForEventFunction,
|
||||
requestUpdateLane_getUpdatePriority,
|
||||
} from './ReactFiberWorkLoop.new';
|
||||
|
||||
import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber';
|
||||
@@ -1670,7 +1672,13 @@ function checkIfSnapshotChanged<T>(inst: StoreInstance<T>): boolean {
|
||||
function forceStoreRerender(fiber) {
|
||||
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
|
||||
scheduleUpdateOnFiber(
|
||||
root,
|
||||
fiber,
|
||||
SyncLane,
|
||||
NoTimestamp,
|
||||
DiscreteEventPriority,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2381,11 +2389,18 @@ function refreshCache<T>(fiber: Fiber, seedKey: ?() => T, seedValue: T) {
|
||||
case HostRoot: {
|
||||
// Schedule an update on the cache boundary to trigger a refresh.
|
||||
const lane = requestUpdateLane(provider);
|
||||
const updatePriority = requestUpdateLane_getUpdatePriority();
|
||||
const eventTime = requestEventTime();
|
||||
const refreshUpdate = createLegacyQueueUpdate(eventTime, lane);
|
||||
const root = enqueueLegacyQueueUpdate(provider, refreshUpdate, lane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, provider, lane, eventTime);
|
||||
scheduleUpdateOnFiber(
|
||||
root,
|
||||
provider,
|
||||
lane,
|
||||
eventTime,
|
||||
updatePriority,
|
||||
);
|
||||
entangleLegacyQueueTransitions(root, provider, lane);
|
||||
}
|
||||
|
||||
@@ -2427,6 +2442,7 @@ function dispatchReducerAction<S, A>(
|
||||
}
|
||||
|
||||
const lane = requestUpdateLane(fiber);
|
||||
const updatePriority = requestUpdateLane_getUpdatePriority();
|
||||
|
||||
const update: Update<S, A> = {
|
||||
lane,
|
||||
@@ -2442,7 +2458,7 @@ function dispatchReducerAction<S, A>(
|
||||
const root = enqueueConcurrentHookUpdate(fiber, queue, update, lane);
|
||||
if (root !== null) {
|
||||
const eventTime = requestEventTime();
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime, updatePriority);
|
||||
entangleTransitionUpdate(root, queue, lane);
|
||||
}
|
||||
}
|
||||
@@ -2466,6 +2482,7 @@ function dispatchSetState<S, A>(
|
||||
}
|
||||
|
||||
const lane = requestUpdateLane(fiber);
|
||||
const updatePriority = requestUpdateLane_getUpdatePriority();
|
||||
|
||||
const update: Update<S, A> = {
|
||||
lane,
|
||||
@@ -2524,7 +2541,7 @@ function dispatchSetState<S, A>(
|
||||
const root = enqueueConcurrentHookUpdate(fiber, queue, update, lane);
|
||||
if (root !== null) {
|
||||
const eventTime = requestEventTime();
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime, updatePriority);
|
||||
entangleTransitionUpdate(root, queue, lane);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +77,7 @@ import {
|
||||
getCurrentUpdatePriority,
|
||||
setCurrentUpdatePriority,
|
||||
higherEventPriority,
|
||||
DiscreteEventPriority,
|
||||
} from './ReactEventPriorities.old';
|
||||
import {readContext, checkIfContextChanged} from './ReactFiberNewContext.old';
|
||||
import {HostRoot, CacheComponent} from './ReactWorkTags';
|
||||
@@ -104,6 +105,7 @@ import {
|
||||
requestEventTime,
|
||||
markSkippedUpdateLanes,
|
||||
isInvalidExecutionContextForEventFunction,
|
||||
requestUpdateLane_getUpdatePriority,
|
||||
} from './ReactFiberWorkLoop.old';
|
||||
|
||||
import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber';
|
||||
@@ -1670,7 +1672,13 @@ function checkIfSnapshotChanged<T>(inst: StoreInstance<T>): boolean {
|
||||
function forceStoreRerender(fiber) {
|
||||
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
|
||||
scheduleUpdateOnFiber(
|
||||
root,
|
||||
fiber,
|
||||
SyncLane,
|
||||
NoTimestamp,
|
||||
DiscreteEventPriority,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2381,11 +2389,18 @@ function refreshCache<T>(fiber: Fiber, seedKey: ?() => T, seedValue: T) {
|
||||
case HostRoot: {
|
||||
// Schedule an update on the cache boundary to trigger a refresh.
|
||||
const lane = requestUpdateLane(provider);
|
||||
const updatePriority = requestUpdateLane_getUpdatePriority();
|
||||
const eventTime = requestEventTime();
|
||||
const refreshUpdate = createLegacyQueueUpdate(eventTime, lane);
|
||||
const root = enqueueLegacyQueueUpdate(provider, refreshUpdate, lane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, provider, lane, eventTime);
|
||||
scheduleUpdateOnFiber(
|
||||
root,
|
||||
provider,
|
||||
lane,
|
||||
eventTime,
|
||||
updatePriority,
|
||||
);
|
||||
entangleLegacyQueueTransitions(root, provider, lane);
|
||||
}
|
||||
|
||||
@@ -2427,6 +2442,7 @@ function dispatchReducerAction<S, A>(
|
||||
}
|
||||
|
||||
const lane = requestUpdateLane(fiber);
|
||||
const updatePriority = requestUpdateLane_getUpdatePriority();
|
||||
|
||||
const update: Update<S, A> = {
|
||||
lane,
|
||||
@@ -2442,7 +2458,7 @@ function dispatchReducerAction<S, A>(
|
||||
const root = enqueueConcurrentHookUpdate(fiber, queue, update, lane);
|
||||
if (root !== null) {
|
||||
const eventTime = requestEventTime();
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime, updatePriority);
|
||||
entangleTransitionUpdate(root, queue, lane);
|
||||
}
|
||||
}
|
||||
@@ -2466,6 +2482,7 @@ function dispatchSetState<S, A>(
|
||||
}
|
||||
|
||||
const lane = requestUpdateLane(fiber);
|
||||
const updatePriority = requestUpdateLane_getUpdatePriority();
|
||||
|
||||
const update: Update<S, A> = {
|
||||
lane,
|
||||
@@ -2524,7 +2541,7 @@ function dispatchSetState<S, A>(
|
||||
const root = enqueueConcurrentHookUpdate(fiber, queue, update, lane);
|
||||
if (root !== null) {
|
||||
const eventTime = requestEventTime();
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime, updatePriority);
|
||||
entangleTransitionUpdate(root, queue, lane);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ import {
|
||||
REACT_LAZY_TYPE,
|
||||
} from 'shared/ReactSymbols';
|
||||
import {enableFloat} from 'shared/ReactFeatureFlags';
|
||||
import {DiscreteEventPriority} from './ReactEventPriorities';
|
||||
|
||||
let resolveFamily: RefreshHandler | null = null;
|
||||
let failedBoundaries: WeakSet<Fiber> | null = null;
|
||||
@@ -314,7 +315,13 @@ function scheduleFibersWithFamiliesRecursively(
|
||||
if (needsRemount || needsRender) {
|
||||
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
|
||||
scheduleUpdateOnFiber(
|
||||
root,
|
||||
fiber,
|
||||
SyncLane,
|
||||
NoTimestamp,
|
||||
DiscreteEventPriority,
|
||||
);
|
||||
}
|
||||
}
|
||||
if (child !== null && !needsRemount) {
|
||||
|
||||
@@ -49,6 +49,7 @@ import {
|
||||
REACT_LAZY_TYPE,
|
||||
} from 'shared/ReactSymbols';
|
||||
import {enableFloat} from 'shared/ReactFeatureFlags';
|
||||
import {DiscreteEventPriority} from './ReactEventPriorities';
|
||||
|
||||
let resolveFamily: RefreshHandler | null = null;
|
||||
let failedBoundaries: WeakSet<Fiber> | null = null;
|
||||
@@ -314,7 +315,13 @@ function scheduleFibersWithFamiliesRecursively(
|
||||
if (needsRemount || needsRender) {
|
||||
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
|
||||
scheduleUpdateOnFiber(
|
||||
root,
|
||||
fiber,
|
||||
SyncLane,
|
||||
NoTimestamp,
|
||||
DiscreteEventPriority,
|
||||
);
|
||||
}
|
||||
}
|
||||
if (child !== null && !needsRemount) {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
import type {Fiber, FiberRoot} from './ReactInternalTypes';
|
||||
import type {Transition} from './ReactFiberTracingMarkerComponent.new';
|
||||
import type {ConcurrentUpdate} from './ReactFiberConcurrentUpdates.new';
|
||||
import type {EventPriority} from './ReactEventPriorities.new';
|
||||
|
||||
// TODO: Ideally these types would be opaque but that doesn't work well with
|
||||
// our reconciler fork infra, since these leak into non-reconciler packages.
|
||||
@@ -588,9 +589,11 @@ export function markRootUpdated(
|
||||
root: FiberRoot,
|
||||
updateLane: Lane,
|
||||
eventTime: number,
|
||||
updatePriority: EventPriority,
|
||||
) {
|
||||
root.pendingLanes |= updateLane;
|
||||
|
||||
root.updatePriority = updatePriority;
|
||||
// If there are any suspended transitions, it's possible this new update
|
||||
// could unblock them. Clear the suspended lanes so that we can try rendering
|
||||
// them again.
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
import type {Fiber, FiberRoot} from './ReactInternalTypes';
|
||||
import type {Transition} from './ReactFiberTracingMarkerComponent.old';
|
||||
import type {ConcurrentUpdate} from './ReactFiberConcurrentUpdates.old';
|
||||
import type {EventPriority} from './ReactEventPriorities.old';
|
||||
|
||||
// TODO: Ideally these types would be opaque but that doesn't work well with
|
||||
// our reconciler fork infra, since these leak into non-reconciler packages.
|
||||
@@ -588,9 +589,11 @@ export function markRootUpdated(
|
||||
root: FiberRoot,
|
||||
updateLane: Lane,
|
||||
eventTime: number,
|
||||
updatePriority: EventPriority,
|
||||
) {
|
||||
root.pendingLanes |= updateLane;
|
||||
|
||||
root.updatePriority = updatePriority;
|
||||
// If there are any suspended transitions, it's possible this new update
|
||||
// could unblock them. Clear the suspended lanes so that we can try rendering
|
||||
// them again.
|
||||
|
||||
@@ -67,6 +67,7 @@ import {
|
||||
deferredUpdates,
|
||||
discreteUpdates,
|
||||
flushPassiveEffects,
|
||||
requestUpdateLane_getUpdatePriority,
|
||||
} from './ReactFiberWorkLoop.new';
|
||||
import {enqueueConcurrentRenderForLane} from './ReactFiberConcurrentUpdates.new';
|
||||
import {
|
||||
@@ -99,6 +100,10 @@ import {
|
||||
findHostInstancesForRefresh,
|
||||
} from './ReactFiberHotReloading.new';
|
||||
import ReactVersion from 'shared/ReactVersion';
|
||||
import {
|
||||
ContinuousEventPriority,
|
||||
DiscreteEventPriority,
|
||||
} from './ReactEventPriorities';
|
||||
export {registerMutableSourceForHydration} from './ReactMutableSource.new';
|
||||
export {createPortal} from './ReactPortal';
|
||||
export {
|
||||
@@ -330,6 +335,7 @@ export function updateContainer(
|
||||
const current = container.current;
|
||||
const eventTime = requestEventTime();
|
||||
const lane = requestUpdateLane(current);
|
||||
const updatePriority = requestUpdateLane_getUpdatePriority();
|
||||
|
||||
if (enableSchedulingProfiler) {
|
||||
markRenderScheduled(lane);
|
||||
@@ -380,7 +386,7 @@ export function updateContainer(
|
||||
|
||||
const root = enqueueUpdate(current, update, lane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, current, lane, eventTime);
|
||||
scheduleUpdateOnFiber(root, current, lane, eventTime, updatePriority);
|
||||
entangleTransitions(root, current, lane);
|
||||
}
|
||||
|
||||
@@ -428,7 +434,13 @@ export function attemptSynchronousHydration(fiber: Fiber): void {
|
||||
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||||
if (root !== null) {
|
||||
const eventTime = requestEventTime();
|
||||
scheduleUpdateOnFiber(root, fiber, SyncLane, eventTime);
|
||||
scheduleUpdateOnFiber(
|
||||
root,
|
||||
fiber,
|
||||
SyncLane,
|
||||
eventTime,
|
||||
DiscreteEventPriority,
|
||||
);
|
||||
}
|
||||
});
|
||||
// If we're still blocked after this, we need to increase
|
||||
@@ -472,7 +484,7 @@ export function attemptDiscreteHydration(fiber: Fiber): void {
|
||||
const root = enqueueConcurrentRenderForLane(fiber, lane);
|
||||
if (root !== null) {
|
||||
const eventTime = requestEventTime();
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime, DiscreteEventPriority);
|
||||
}
|
||||
markRetryLaneIfNotHydrated(fiber, lane);
|
||||
}
|
||||
@@ -489,7 +501,13 @@ export function attemptContinuousHydration(fiber: Fiber): void {
|
||||
const root = enqueueConcurrentRenderForLane(fiber, lane);
|
||||
if (root !== null) {
|
||||
const eventTime = requestEventTime();
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
|
||||
scheduleUpdateOnFiber(
|
||||
root,
|
||||
fiber,
|
||||
lane,
|
||||
eventTime,
|
||||
ContinuousEventPriority,
|
||||
);
|
||||
}
|
||||
markRetryLaneIfNotHydrated(fiber, lane);
|
||||
}
|
||||
@@ -501,10 +519,11 @@ export function attemptHydrationAtCurrentPriority(fiber: Fiber): void {
|
||||
return;
|
||||
}
|
||||
const lane = requestUpdateLane(fiber);
|
||||
const updatePriority = requestUpdateLane_getUpdatePriority();
|
||||
const root = enqueueConcurrentRenderForLane(fiber, lane);
|
||||
if (root !== null) {
|
||||
const eventTime = requestEventTime();
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime, updatePriority);
|
||||
}
|
||||
markRetryLaneIfNotHydrated(fiber, lane);
|
||||
}
|
||||
@@ -683,7 +702,13 @@ if (__DEV__) {
|
||||
|
||||
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
|
||||
scheduleUpdateOnFiber(
|
||||
root,
|
||||
fiber,
|
||||
SyncLane,
|
||||
NoTimestamp,
|
||||
root.updatePriority,
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -707,7 +732,13 @@ if (__DEV__) {
|
||||
|
||||
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
|
||||
scheduleUpdateOnFiber(
|
||||
root,
|
||||
fiber,
|
||||
SyncLane,
|
||||
NoTimestamp,
|
||||
root.updatePriority,
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -732,7 +763,13 @@ if (__DEV__) {
|
||||
|
||||
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
|
||||
scheduleUpdateOnFiber(
|
||||
root,
|
||||
fiber,
|
||||
SyncLane,
|
||||
NoTimestamp,
|
||||
root.updatePriority,
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -745,7 +782,13 @@ if (__DEV__) {
|
||||
}
|
||||
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
|
||||
scheduleUpdateOnFiber(
|
||||
root,
|
||||
fiber,
|
||||
SyncLane,
|
||||
NoTimestamp,
|
||||
root.updatePriority,
|
||||
);
|
||||
}
|
||||
};
|
||||
overridePropsDeletePath = (fiber: Fiber, path: Array<string | number>) => {
|
||||
@@ -755,7 +798,13 @@ if (__DEV__) {
|
||||
}
|
||||
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
|
||||
scheduleUpdateOnFiber(
|
||||
root,
|
||||
fiber,
|
||||
SyncLane,
|
||||
NoTimestamp,
|
||||
root.updatePriority,
|
||||
);
|
||||
}
|
||||
};
|
||||
overridePropsRenamePath = (
|
||||
@@ -769,14 +818,26 @@ if (__DEV__) {
|
||||
}
|
||||
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
|
||||
scheduleUpdateOnFiber(
|
||||
root,
|
||||
fiber,
|
||||
SyncLane,
|
||||
NoTimestamp,
|
||||
root.updatePriority,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
scheduleUpdate = (fiber: Fiber) => {
|
||||
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
|
||||
scheduleUpdateOnFiber(
|
||||
root,
|
||||
fiber,
|
||||
SyncLane,
|
||||
NoTimestamp,
|
||||
root.updatePriority,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ import {
|
||||
deferredUpdates,
|
||||
discreteUpdates,
|
||||
flushPassiveEffects,
|
||||
requestUpdateLane_getUpdatePriority,
|
||||
} from './ReactFiberWorkLoop.old';
|
||||
import {enqueueConcurrentRenderForLane} from './ReactFiberConcurrentUpdates.old';
|
||||
import {
|
||||
@@ -99,6 +100,10 @@ import {
|
||||
findHostInstancesForRefresh,
|
||||
} from './ReactFiberHotReloading.old';
|
||||
import ReactVersion from 'shared/ReactVersion';
|
||||
import {
|
||||
ContinuousEventPriority,
|
||||
DiscreteEventPriority,
|
||||
} from './ReactEventPriorities';
|
||||
export {registerMutableSourceForHydration} from './ReactMutableSource.old';
|
||||
export {createPortal} from './ReactPortal';
|
||||
export {
|
||||
@@ -330,6 +335,7 @@ export function updateContainer(
|
||||
const current = container.current;
|
||||
const eventTime = requestEventTime();
|
||||
const lane = requestUpdateLane(current);
|
||||
const updatePriority = requestUpdateLane_getUpdatePriority();
|
||||
|
||||
if (enableSchedulingProfiler) {
|
||||
markRenderScheduled(lane);
|
||||
@@ -380,7 +386,7 @@ export function updateContainer(
|
||||
|
||||
const root = enqueueUpdate(current, update, lane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, current, lane, eventTime);
|
||||
scheduleUpdateOnFiber(root, current, lane, eventTime, updatePriority);
|
||||
entangleTransitions(root, current, lane);
|
||||
}
|
||||
|
||||
@@ -428,7 +434,13 @@ export function attemptSynchronousHydration(fiber: Fiber): void {
|
||||
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||||
if (root !== null) {
|
||||
const eventTime = requestEventTime();
|
||||
scheduleUpdateOnFiber(root, fiber, SyncLane, eventTime);
|
||||
scheduleUpdateOnFiber(
|
||||
root,
|
||||
fiber,
|
||||
SyncLane,
|
||||
eventTime,
|
||||
DiscreteEventPriority,
|
||||
);
|
||||
}
|
||||
});
|
||||
// If we're still blocked after this, we need to increase
|
||||
@@ -472,7 +484,7 @@ export function attemptDiscreteHydration(fiber: Fiber): void {
|
||||
const root = enqueueConcurrentRenderForLane(fiber, lane);
|
||||
if (root !== null) {
|
||||
const eventTime = requestEventTime();
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime, DiscreteEventPriority);
|
||||
}
|
||||
markRetryLaneIfNotHydrated(fiber, lane);
|
||||
}
|
||||
@@ -489,7 +501,13 @@ export function attemptContinuousHydration(fiber: Fiber): void {
|
||||
const root = enqueueConcurrentRenderForLane(fiber, lane);
|
||||
if (root !== null) {
|
||||
const eventTime = requestEventTime();
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
|
||||
scheduleUpdateOnFiber(
|
||||
root,
|
||||
fiber,
|
||||
lane,
|
||||
eventTime,
|
||||
ContinuousEventPriority,
|
||||
);
|
||||
}
|
||||
markRetryLaneIfNotHydrated(fiber, lane);
|
||||
}
|
||||
@@ -501,10 +519,11 @@ export function attemptHydrationAtCurrentPriority(fiber: Fiber): void {
|
||||
return;
|
||||
}
|
||||
const lane = requestUpdateLane(fiber);
|
||||
const updatePriority = requestUpdateLane_getUpdatePriority();
|
||||
const root = enqueueConcurrentRenderForLane(fiber, lane);
|
||||
if (root !== null) {
|
||||
const eventTime = requestEventTime();
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
|
||||
scheduleUpdateOnFiber(root, fiber, lane, eventTime, updatePriority);
|
||||
}
|
||||
markRetryLaneIfNotHydrated(fiber, lane);
|
||||
}
|
||||
@@ -683,7 +702,13 @@ if (__DEV__) {
|
||||
|
||||
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
|
||||
scheduleUpdateOnFiber(
|
||||
root,
|
||||
fiber,
|
||||
SyncLane,
|
||||
NoTimestamp,
|
||||
root.updatePriority,
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -707,7 +732,13 @@ if (__DEV__) {
|
||||
|
||||
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
|
||||
scheduleUpdateOnFiber(
|
||||
root,
|
||||
fiber,
|
||||
SyncLane,
|
||||
NoTimestamp,
|
||||
root.updatePriority,
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -732,7 +763,13 @@ if (__DEV__) {
|
||||
|
||||
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
|
||||
scheduleUpdateOnFiber(
|
||||
root,
|
||||
fiber,
|
||||
SyncLane,
|
||||
NoTimestamp,
|
||||
root.updatePriority,
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -745,7 +782,13 @@ if (__DEV__) {
|
||||
}
|
||||
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
|
||||
scheduleUpdateOnFiber(
|
||||
root,
|
||||
fiber,
|
||||
SyncLane,
|
||||
NoTimestamp,
|
||||
root.updatePriority,
|
||||
);
|
||||
}
|
||||
};
|
||||
overridePropsDeletePath = (fiber: Fiber, path: Array<string | number>) => {
|
||||
@@ -755,7 +798,13 @@ if (__DEV__) {
|
||||
}
|
||||
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
|
||||
scheduleUpdateOnFiber(
|
||||
root,
|
||||
fiber,
|
||||
SyncLane,
|
||||
NoTimestamp,
|
||||
root.updatePriority,
|
||||
);
|
||||
}
|
||||
};
|
||||
overridePropsRenamePath = (
|
||||
@@ -769,14 +818,26 @@ if (__DEV__) {
|
||||
}
|
||||
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
|
||||
scheduleUpdateOnFiber(
|
||||
root,
|
||||
fiber,
|
||||
SyncLane,
|
||||
NoTimestamp,
|
||||
root.updatePriority,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
scheduleUpdate = (fiber: Fiber) => {
|
||||
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
|
||||
if (root !== null) {
|
||||
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
|
||||
scheduleUpdateOnFiber(
|
||||
root,
|
||||
fiber,
|
||||
SyncLane,
|
||||
NoTimestamp,
|
||||
root.updatePriority,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ function FiberRootNode(
|
||||
this.pendingContext = null;
|
||||
this.callbackNode = null;
|
||||
this.callbackPriority = NoEventPriority;
|
||||
this.updatePriority = NoEventPriority;
|
||||
this.eventTimes = createLaneMap(NoLanes);
|
||||
this.expirationTimes = createLaneMap(NoTimestamp);
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ function FiberRootNode(
|
||||
this.pendingContext = null;
|
||||
this.callbackNode = null;
|
||||
this.callbackPriority = NoEventPriority;
|
||||
this.updatePriority = NoEventPriority;
|
||||
this.eventTimes = createLaneMap(NoLanes);
|
||||
this.expirationTimes = createLaneMap(NoTimestamp);
|
||||
|
||||
|
||||
@@ -603,10 +603,18 @@ export function getCurrentTime(): number {
|
||||
return now();
|
||||
}
|
||||
|
||||
let currentUpdatePriority = NoEventPriority;
|
||||
|
||||
export function requestUpdateLane_getUpdatePriority(): EventPriority {
|
||||
return currentUpdatePriority;
|
||||
}
|
||||
|
||||
export function requestUpdateLane(fiber: Fiber): Lane {
|
||||
currentUpdatePriority = NoEventPriority;
|
||||
// Special cases
|
||||
const mode = fiber.mode;
|
||||
if ((mode & ConcurrentMode) === NoMode) {
|
||||
currentUpdatePriority = DiscreteEventPriority;
|
||||
return (SyncLane: Lane);
|
||||
} else if (
|
||||
!deferRenderPhaseUpdateToNextBatch &&
|
||||
@@ -655,6 +663,7 @@ export function requestUpdateLane(fiber: Fiber): Lane {
|
||||
// TODO: Move this type conversion to the event priority module.
|
||||
const updatePriority = getCurrentUpdatePriority();
|
||||
if (updatePriority !== NoEventPriority) {
|
||||
currentUpdatePriority = updatePriority;
|
||||
if (updatePriority === DefaultEventPriority) {
|
||||
return DefaultLane;
|
||||
}
|
||||
@@ -669,6 +678,7 @@ export function requestUpdateLane(fiber: Fiber): Lane {
|
||||
//
|
||||
// TODO: Move this type conversion to the event priority module.
|
||||
const eventPriority = getCurrentEventPriority();
|
||||
currentUpdatePriority = eventPriority;
|
||||
if (eventPriority === DefaultEventPriority) {
|
||||
return DefaultLane;
|
||||
}
|
||||
@@ -697,6 +707,7 @@ export function scheduleUpdateOnFiber(
|
||||
fiber: Fiber,
|
||||
lane: Lane,
|
||||
eventTime: number,
|
||||
updatePriority: EventPriority,
|
||||
) {
|
||||
if (__DEV__) {
|
||||
if (isRunningInsertionEffect) {
|
||||
@@ -711,7 +722,7 @@ export function scheduleUpdateOnFiber(
|
||||
}
|
||||
|
||||
// Mark that the root has a pending update.
|
||||
markRootUpdated(root, lane, eventTime);
|
||||
markRootUpdated(root, lane, eventTime, updatePriority);
|
||||
|
||||
if (
|
||||
(executionContext & RenderContext) !== NoLanes &&
|
||||
@@ -832,7 +843,7 @@ export function scheduleInitialHydrationOnRoot(
|
||||
// match what was rendered on the server.
|
||||
const current = root.current;
|
||||
current.lanes = lane;
|
||||
markRootUpdated(root, lane, eventTime);
|
||||
markRootUpdated(root, lane, eventTime, root.updatePriority);
|
||||
ensureRootIsScheduled(root, eventTime);
|
||||
}
|
||||
|
||||
@@ -2651,6 +2662,7 @@ function commitRootImpl(
|
||||
// are consolidated.
|
||||
if (
|
||||
includesSomeLane(pendingPassiveEffectsLanes, SyncLane) &&
|
||||
root.updatePriority === DiscreteEventPriority &&
|
||||
root.tag !== LegacyRoot
|
||||
) {
|
||||
flushPassiveEffects();
|
||||
@@ -2965,7 +2977,7 @@ function captureCommitPhaseErrorOnRoot(
|
||||
const root = enqueueUpdate(rootFiber, update, (SyncLane: Lane));
|
||||
const eventTime = requestEventTime();
|
||||
if (root !== null) {
|
||||
markRootUpdated(root, SyncLane, eventTime);
|
||||
markRootUpdated(root, SyncLane, eventTime, DiscreteEventPriority);
|
||||
ensureRootIsScheduled(root, eventTime);
|
||||
}
|
||||
}
|
||||
@@ -3014,7 +3026,7 @@ export function captureCommitPhaseError(
|
||||
const root = enqueueUpdate(fiber, update, (SyncLane: Lane));
|
||||
const eventTime = requestEventTime();
|
||||
if (root !== null) {
|
||||
markRootUpdated(root, SyncLane, eventTime);
|
||||
markRootUpdated(root, SyncLane, eventTime, DiscreteEventPriority);
|
||||
ensureRootIsScheduled(root, eventTime);
|
||||
}
|
||||
return;
|
||||
@@ -3150,7 +3162,7 @@ function retryTimedOutBoundary(boundaryFiber: Fiber, retryLane: Lane) {
|
||||
const eventTime = requestEventTime();
|
||||
const root = enqueueConcurrentRenderForLane(boundaryFiber, retryLane);
|
||||
if (root !== null) {
|
||||
markRootUpdated(root, retryLane, eventTime);
|
||||
markRootUpdated(root, retryLane, eventTime, root.updatePriority);
|
||||
ensureRootIsScheduled(root, eventTime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -603,10 +603,18 @@ export function getCurrentTime(): number {
|
||||
return now();
|
||||
}
|
||||
|
||||
let currentUpdatePriority = NoEventPriority;
|
||||
|
||||
export function requestUpdateLane_getUpdatePriority(): EventPriority {
|
||||
return currentUpdatePriority;
|
||||
}
|
||||
|
||||
export function requestUpdateLane(fiber: Fiber): Lane {
|
||||
currentUpdatePriority = NoEventPriority;
|
||||
// Special cases
|
||||
const mode = fiber.mode;
|
||||
if ((mode & ConcurrentMode) === NoMode) {
|
||||
currentUpdatePriority = DiscreteEventPriority;
|
||||
return (SyncLane: Lane);
|
||||
} else if (
|
||||
!deferRenderPhaseUpdateToNextBatch &&
|
||||
@@ -655,6 +663,7 @@ export function requestUpdateLane(fiber: Fiber): Lane {
|
||||
// TODO: Move this type conversion to the event priority module.
|
||||
const updatePriority = getCurrentUpdatePriority();
|
||||
if (updatePriority !== NoEventPriority) {
|
||||
currentUpdatePriority = updatePriority;
|
||||
if (updatePriority === DefaultEventPriority) {
|
||||
return DefaultLane;
|
||||
}
|
||||
@@ -669,6 +678,7 @@ export function requestUpdateLane(fiber: Fiber): Lane {
|
||||
//
|
||||
// TODO: Move this type conversion to the event priority module.
|
||||
const eventPriority = getCurrentEventPriority();
|
||||
currentUpdatePriority = eventPriority;
|
||||
if (eventPriority === DefaultEventPriority) {
|
||||
return DefaultLane;
|
||||
}
|
||||
@@ -697,6 +707,7 @@ export function scheduleUpdateOnFiber(
|
||||
fiber: Fiber,
|
||||
lane: Lane,
|
||||
eventTime: number,
|
||||
updatePriority: EventPriority,
|
||||
) {
|
||||
if (__DEV__) {
|
||||
if (isRunningInsertionEffect) {
|
||||
@@ -711,7 +722,7 @@ export function scheduleUpdateOnFiber(
|
||||
}
|
||||
|
||||
// Mark that the root has a pending update.
|
||||
markRootUpdated(root, lane, eventTime);
|
||||
markRootUpdated(root, lane, eventTime, updatePriority);
|
||||
|
||||
if (
|
||||
(executionContext & RenderContext) !== NoLanes &&
|
||||
@@ -832,7 +843,7 @@ export function scheduleInitialHydrationOnRoot(
|
||||
// match what was rendered on the server.
|
||||
const current = root.current;
|
||||
current.lanes = lane;
|
||||
markRootUpdated(root, lane, eventTime);
|
||||
markRootUpdated(root, lane, eventTime, root.updatePriority);
|
||||
ensureRootIsScheduled(root, eventTime);
|
||||
}
|
||||
|
||||
@@ -2651,6 +2662,7 @@ function commitRootImpl(
|
||||
// are consolidated.
|
||||
if (
|
||||
includesSomeLane(pendingPassiveEffectsLanes, SyncLane) &&
|
||||
root.updatePriority === DiscreteEventPriority &&
|
||||
root.tag !== LegacyRoot
|
||||
) {
|
||||
flushPassiveEffects();
|
||||
@@ -2965,7 +2977,7 @@ function captureCommitPhaseErrorOnRoot(
|
||||
const root = enqueueUpdate(rootFiber, update, (SyncLane: Lane));
|
||||
const eventTime = requestEventTime();
|
||||
if (root !== null) {
|
||||
markRootUpdated(root, SyncLane, eventTime);
|
||||
markRootUpdated(root, SyncLane, eventTime, DiscreteEventPriority);
|
||||
ensureRootIsScheduled(root, eventTime);
|
||||
}
|
||||
}
|
||||
@@ -3014,7 +3026,7 @@ export function captureCommitPhaseError(
|
||||
const root = enqueueUpdate(fiber, update, (SyncLane: Lane));
|
||||
const eventTime = requestEventTime();
|
||||
if (root !== null) {
|
||||
markRootUpdated(root, SyncLane, eventTime);
|
||||
markRootUpdated(root, SyncLane, eventTime, DiscreteEventPriority);
|
||||
ensureRootIsScheduled(root, eventTime);
|
||||
}
|
||||
return;
|
||||
@@ -3150,7 +3162,7 @@ function retryTimedOutBoundary(boundaryFiber: Fiber, retryLane: Lane) {
|
||||
const eventTime = requestEventTime();
|
||||
const root = enqueueConcurrentRenderForLane(boundaryFiber, retryLane);
|
||||
if (root !== null) {
|
||||
markRootUpdated(root, retryLane, eventTime);
|
||||
markRootUpdated(root, retryLane, eventTime, root.updatePriority);
|
||||
ensureRootIsScheduled(root, eventTime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,6 +241,7 @@ type BaseFiberRootProperties = {
|
||||
// task that the root will work on.
|
||||
callbackNode: any,
|
||||
callbackPriority: EventPriority,
|
||||
updatePriority: EventPriority,
|
||||
eventTimes: LaneMap<number>,
|
||||
expirationTimes: LaneMap<number>,
|
||||
hiddenUpdates: LaneMap<Array<ConcurrentUpdate> | null>,
|
||||
|
||||
Reference in New Issue
Block a user