Fix remaining tests

This commit is contained in:
Tianyu Yao 2022-10-21 19:26:47 -07:00
parent 9d8c26e1d3
commit 4f7c7d8dea
4 changed files with 23 additions and 10 deletions

View File

@ -2497,6 +2497,7 @@ function commitRootImpl(
}
}
const rootUpdatePriorityBeforeLayoutEffect = root.updatePriority;
// Check if there are any effects in the whole tree.
// TODO: This is left over from the effect list implementation, where we had
// to check for the existence of `firstEffect` to satisfy Flow. I think the
@ -2697,9 +2698,11 @@ function commitRootImpl(
// TODO: We can optimize this by not scheduling the callback earlier. Since we
// currently schedule the callback in multiple places, will wait until those
// are consolidated.
//// TODO: Should we flushPassiveEffects When `pendingPassiveEffectsLanes` is a retry lane?
if (
(enableUnifiedSyncLane
? root.updatePriority === DiscreteEventPriority
? includesSomeLane(pendingPassiveEffectsLanes, SyncLane) &&
rootUpdatePriorityBeforeLayoutEffect === DiscreteEventPriority
: includesSomeLane(pendingPassiveEffectsLanes, SyncLane)) &&
root.tag !== LegacyRoot
) {
@ -2708,7 +2711,7 @@ function commitRootImpl(
// Read this again, since a passive effect might have updated it
remainingLanes = root.pendingLanes;
if (includesSomeLane(remainingLanes, (SyncLane: Lane))) {
if (includesSomeLane(remainingLanes, SyncLane)) {
if (enableProfilerTimer && enableProfilerNestedUpdatePhase) {
markNestedUpdateScheduled();
}

View File

@ -2497,6 +2497,7 @@ function commitRootImpl(
}
}
const rootUpdatePriorityBeforeLayoutEffect = root.updatePriority;
// Check if there are any effects in the whole tree.
// TODO: This is left over from the effect list implementation, where we had
// to check for the existence of `firstEffect` to satisfy Flow. I think the
@ -2697,9 +2698,11 @@ function commitRootImpl(
// TODO: We can optimize this by not scheduling the callback earlier. Since we
// currently schedule the callback in multiple places, will wait until those
// are consolidated.
//// TODO: Should we flushPassiveEffects When `pendingPassiveEffectsLanes` is a retry lane?
if (
(enableUnifiedSyncLane
? root.updatePriority === DiscreteEventPriority
? includesSomeLane(pendingPassiveEffectsLanes, SyncLane) &&
rootUpdatePriorityBeforeLayoutEffect === DiscreteEventPriority
: includesSomeLane(pendingPassiveEffectsLanes, SyncLane)) &&
root.tag !== LegacyRoot
) {
@ -2708,7 +2711,7 @@ function commitRootImpl(
// Read this again, since a passive effect might have updated it
remainingLanes = root.pendingLanes;
if (includesSomeLane(remainingLanes, (SyncLane: Lane))) {
if (includesSomeLane(remainingLanes, SyncLane)) {
if (enableProfilerTimer && enableProfilerNestedUpdatePhase) {
markNestedUpdateScheduled();
}

View File

@ -371,10 +371,15 @@ describe('updaters', () => {
onCommitRootShouldYield = true;
await act(async () => {
triggerError();
if (gate(flags => flags.enableUnifiedSyncLane)) {
React.startTransition(() => {
triggerError();
});
} else {
triggerError();
}
});
expect(Scheduler).toHaveYielded(['onCommitRoot', 'error', 'onCommitRoot']);
//// TODO: ??
expect(allSchedulerTypes).toEqual([[Parent], [ErrorBoundary]]);
// Verify no outstanding flushes

View File

@ -454,11 +454,13 @@ describe('useSubscription', () => {
observableA.next('a-2');
// Update again
//// TODO: ???
// renderer.update(<Parent observed={observableA} />);
React.startTransition(() => {
if (gate(flags => flags.enableUnifiedSyncLane)) {
React.startTransition(() => {
renderer.update(<Parent observed={observableA} />);
});
} else {
renderer.update(<Parent observed={observableA} />);
});
}
// Flush everything and ensure that the correct subscribable is used
expect(Scheduler).toFlushAndYield([