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

Function completeUnitOfWork

code/styling/public/app.js:13070–13214  ·  view source on GitHub ↗
(workInProgress)

Source from the content-addressed store, hash-verified

13068 }
13069
13070 function completeUnitOfWork(workInProgress) {
13071 // Attempt to complete the current unit of work, then move to the
13072 // next sibling. If there are no more siblings, return to the
13073 // parent fiber.
13074 while (true) {
13075 // The current, flushed, state of this fiber is the alternate.
13076 // Ideally nothing should rely on this, but relying on it here
13077 // means that we don't need an additional field on the work in
13078 // progress.
13079 var current = workInProgress.alternate;
13080 {
13081 ReactDebugCurrentFiber.setCurrentFiber(workInProgress);
13082 }
13083
13084 var returnFiber = workInProgress['return'];
13085 var siblingFiber = workInProgress.sibling;
13086
13087 if ((workInProgress.effectTag & Incomplete) === NoEffect) {
13088 // This fiber completed.
13089 var next = completeWork(current, workInProgress, nextRenderExpirationTime);
13090 stopWorkTimer(workInProgress);
13091 resetExpirationTime(workInProgress, nextRenderExpirationTime);
13092 {
13093 ReactDebugCurrentFiber.resetCurrentFiber();
13094 }
13095
13096 if (next !== null) {
13097 stopWorkTimer(workInProgress);
13098 if (true && ReactFiberInstrumentation_1.debugTool) {
13099 ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress);
13100 }
13101 // If completing this work spawned new work, do that next. We'll come
13102 // back here again.
13103 return next;
13104 }
13105
13106 if (returnFiber !== null &&
13107 // Do not append effects to parents if a sibling failed to complete
13108 (returnFiber.effectTag & Incomplete) === NoEffect) {
13109 // Append all the effects of the subtree and this fiber onto the effect
13110 // list of the parent. The completion order of the children affects the
13111 // side-effect order.
13112 if (returnFiber.firstEffect === null) {
13113 returnFiber.firstEffect = workInProgress.firstEffect;
13114 }
13115 if (workInProgress.lastEffect !== null) {
13116 if (returnFiber.lastEffect !== null) {
13117 returnFiber.lastEffect.nextEffect = workInProgress.firstEffect;
13118 }
13119 returnFiber.lastEffect = workInProgress.lastEffect;
13120 }
13121
13122 // If this fiber had side-effects, we append it AFTER the children's
13123 // side-effects. We can perform certain side-effects earlier if
13124 // needed, by doing multiple passes over the effect list. We don't want
13125 // to schedule our own side-effect on our own list because if end up
13126 // reusing children we'll schedule this effect onto itself since we're
13127 // 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