Skip to content

Commit 1fb719b

Browse files
committed
old
1 parent eb94785 commit 1fb719b

File tree

1 file changed

+32
-17
lines changed

1 file changed

+32
-17
lines changed

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

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ import {
8282
supportsMicrotasks,
8383
errorHydratingContainer,
8484
scheduleMicrotask,
85+
requestPostPaintCallback,
8586
} from './ReactFiberHostConfig';
8687

8788
import {
@@ -350,6 +351,7 @@ export function getWorkInProgressTransitions() {
350351
}
351352

352353
let currentPendingTransitionCallbacks: PendingTransitionCallbacks | null = null;
354+
let currentEndTime: number | null = null;
353355

354356
export function addTransitionStartCallbackToPendingTransition(
355357
transition: Transition,
@@ -2514,6 +2516,24 @@ function commitRootImpl(
25142516
markCommitStopped();
25152517
}
25162518

2519+
const prevRootTransitionCallbacks = root.transitionCallbacks;
2520+
if (prevRootTransitionCallbacks !== null) {
2521+
requestPostPaintCallback(endTime => {
2522+
const prevPendingTransitionCallbacks = currentPendingTransitionCallbacks;
2523+
if (prevPendingTransitionCallbacks !== null) {
2524+
scheduleCallback(IdleSchedulerPriority, () => {
2525+
processTransitionCallbacks(
2526+
prevPendingTransitionCallbacks,
2527+
endTime,
2528+
prevRootTransitionCallbacks,
2529+
);
2530+
});
2531+
} else {
2532+
currentEndTime = endTime;
2533+
}
2534+
});
2535+
}
2536+
25172537
return null;
25182538
}
25192539

@@ -2655,28 +2675,23 @@ function flushPassiveEffectsImpl() {
26552675
if (enableTransitionTracing) {
26562676
const prevPendingTransitionCallbacks = currentPendingTransitionCallbacks;
26572677
const prevRootTransitionCallbacks = root.transitionCallbacks;
2678+
const prevEndTime = currentEndTime;
26582679
if (
26592680
prevPendingTransitionCallbacks !== null &&
26602681
prevRootTransitionCallbacks !== null
26612682
) {
2662-
// TODO(luna) Refactor this code into the Host Config
2663-
// TODO(luna) The end time here is not necessarily accurate
2664-
// because passive effects could be called before paint
2665-
// (synchronously) or after paint (normally). We need
2666-
// to come up with a way to get the correct end time for both cases.
2667-
// One solution is in the host config, if the passive effects
2668-
// have not yet been run, make a call to flush the passive effects
2669-
// right after paint.
2670-
const endTime = now();
26712683
currentPendingTransitionCallbacks = null;
2672-
2673-
scheduleCallback(IdleSchedulerPriority, () =>
2674-
processTransitionCallbacks(
2675-
prevPendingTransitionCallbacks,
2676-
endTime,
2677-
prevRootTransitionCallbacks,
2678-
),
2679-
);
2684+
currentEndTime = null;
2685+
2686+
if (prevEndTime !== null) {
2687+
scheduleCallback(IdleSchedulerPriority, () =>
2688+
processTransitionCallbacks(
2689+
prevPendingTransitionCallbacks,
2690+
prevEndTime,
2691+
prevRootTransitionCallbacks,
2692+
),
2693+
);
2694+
}
26802695
}
26812696
}
26822697

0 commit comments

Comments
 (0)