MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / completeUnitOfWork

Function completeUnitOfWork

code/event-handlers/public/app.js:12400–12544  ·  view source on GitHub ↗
(workInProgress)

Source from the content-addressed store, hash-verified

12398 }
12399
12400 function completeUnitOfWork(workInProgress) {
12401 // Attempt to complete the current unit of work, then move to the
12402 // next sibling. If there are no more siblings, return to the
12403 // parent fiber.
12404 while (true) {
12405 // The current, flushed, state of this fiber is the alternate.
12406 // Ideally nothing should rely on this, but relying on it here
12407 // means that we don't need an additional field on the work in
12408 // progress.
12409 var current = workInProgress.alternate;
12410 {
12411 ReactDebugCurrentFiber.setCurrentFiber(workInProgress);
12412 }
12413
12414 var returnFiber = workInProgress['return'];
12415 var siblingFiber = workInProgress.sibling;
12416
12417 if ((workInProgress.effectTag & Incomplete) === NoEffect) {
12418 // This fiber completed.
12419 var next = completeWork(current, workInProgress, nextRenderExpirationTime);
12420 stopWorkTimer(workInProgress);
12421 resetExpirationTime(workInProgress, nextRenderExpirationTime);
12422 {
12423 ReactDebugCurrentFiber.resetCurrentFiber();
12424 }
12425
12426 if (next !== null) {
12427 stopWorkTimer(workInProgress);
12428 if (true && ReactFiberInstrumentation_1.debugTool) {
12429 ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress);
12430 }
12431 // If completing this work spawned new work, do that next. We'll come
12432 // back here again.
12433 return next;
12434 }
12435
12436 if (returnFiber !== null &&
12437 // Do not append effects to parents if a sibling failed to complete
12438 (returnFiber.effectTag & Incomplete) === NoEffect) {
12439 // Append all the effects of the subtree and this fiber onto the effect
12440 // list of the parent. The completion order of the children affects the
12441 // side-effect order.
12442 if (returnFiber.firstEffect === null) {
12443 returnFiber.firstEffect = workInProgress.firstEffect;
12444 }
12445 if (workInProgress.lastEffect !== null) {
12446 if (returnFiber.lastEffect !== null) {
12447 returnFiber.lastEffect.nextEffect = workInProgress.firstEffect;
12448 }
12449 returnFiber.lastEffect = workInProgress.lastEffect;
12450 }
12451
12452 // If this fiber had side-effects, we append it AFTER the children's
12453 // side-effects. We can perform certain side-effects earlier if
12454 // needed, by doing multiple passes over the effect list. We don't want
12455 // to schedule our own side-effect on our own list because if end up
12456 // reusing children we'll schedule this effect onto itself since we're
12457 // at the end.

Callers 2

performUnitOfWorkFunction · 0.70
renderRootFunction · 0.70

Calls 5

completeWorkFunction · 0.70
stopWorkTimerFunction · 0.70
resetExpirationTimeFunction · 0.70
unwindWorkFunction · 0.70
stopFailedWorkTimerFunction · 0.70

Tested by

no test coverage detected