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

Function completeUnitOfWork

code/new-context-api/public/app.js:12431–12575  ·  view source on GitHub ↗
(workInProgress)

Source from the content-addressed store, hash-verified

12429 }
12430
12431 function completeUnitOfWork(workInProgress) {
12432 // Attempt to complete the current unit of work, then move to the
12433 // next sibling. If there are no more siblings, return to the
12434 // parent fiber.
12435 while (true) {
12436 // The current, flushed, state of this fiber is the alternate.
12437 // Ideally nothing should rely on this, but relying on it here
12438 // means that we don't need an additional field on the work in
12439 // progress.
12440 var current = workInProgress.alternate;
12441 {
12442 ReactDebugCurrentFiber.setCurrentFiber(workInProgress);
12443 }
12444
12445 var returnFiber = workInProgress['return'];
12446 var siblingFiber = workInProgress.sibling;
12447
12448 if ((workInProgress.effectTag & Incomplete) === NoEffect) {
12449 // This fiber completed.
12450 var next = completeWork(current, workInProgress, nextRenderExpirationTime);
12451 stopWorkTimer(workInProgress);
12452 resetExpirationTime(workInProgress, nextRenderExpirationTime);
12453 {
12454 ReactDebugCurrentFiber.resetCurrentFiber();
12455 }
12456
12457 if (next !== null) {
12458 stopWorkTimer(workInProgress);
12459 if (true && ReactFiberInstrumentation_1.debugTool) {
12460 ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress);
12461 }
12462 // If completing this work spawned new work, do that next. We'll come
12463 // back here again.
12464 return next;
12465 }
12466
12467 if (returnFiber !== null &&
12468 // Do not append effects to parents if a sibling failed to complete
12469 (returnFiber.effectTag & Incomplete) === NoEffect) {
12470 // Append all the effects of the subtree and this fiber onto the effect
12471 // list of the parent. The completion order of the children affects the
12472 // side-effect order.
12473 if (returnFiber.firstEffect === null) {
12474 returnFiber.firstEffect = workInProgress.firstEffect;
12475 }
12476 if (workInProgress.lastEffect !== null) {
12477 if (returnFiber.lastEffect !== null) {
12478 returnFiber.lastEffect.nextEffect = workInProgress.firstEffect;
12479 }
12480 returnFiber.lastEffect = workInProgress.lastEffect;
12481 }
12482
12483 // If this fiber had side-effects, we append it AFTER the children's
12484 // side-effects. We can perform certain side-effects earlier if
12485 // needed, by doing multiple passes over the effect list. We don't want
12486 // to schedule our own side-effect on our own list because if end up
12487 // reusing children we'll schedule this effect onto itself since we're
12488 // 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