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

Function completeUnitOfWork

code/communication/public/app.js:13105–13249  ·  view source on GitHub ↗
(workInProgress)

Source from the content-addressed store, hash-verified

13103 }
13104
13105 function completeUnitOfWork(workInProgress) {
13106 // Attempt to complete the current unit of work, then move to the
13107 // next sibling. If there are no more siblings, return to the
13108 // parent fiber.
13109 while (true) {
13110 // The current, flushed, state of this fiber is the alternate.
13111 // Ideally nothing should rely on this, but relying on it here
13112 // means that we don't need an additional field on the work in
13113 // progress.
13114 var current = workInProgress.alternate;
13115 {
13116 ReactDebugCurrentFiber.setCurrentFiber(workInProgress);
13117 }
13118
13119 var returnFiber = workInProgress['return'];
13120 var siblingFiber = workInProgress.sibling;
13121
13122 if ((workInProgress.effectTag & Incomplete) === NoEffect) {
13123 // This fiber completed.
13124 var next = completeWork(current, workInProgress, nextRenderExpirationTime);
13125 stopWorkTimer(workInProgress);
13126 resetExpirationTime(workInProgress, nextRenderExpirationTime);
13127 {
13128 ReactDebugCurrentFiber.resetCurrentFiber();
13129 }
13130
13131 if (next !== null) {
13132 stopWorkTimer(workInProgress);
13133 if (true && ReactFiberInstrumentation_1.debugTool) {
13134 ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress);
13135 }
13136 // If completing this work spawned new work, do that next. We'll come
13137 // back here again.
13138 return next;
13139 }
13140
13141 if (returnFiber !== null &&
13142 // Do not append effects to parents if a sibling failed to complete
13143 (returnFiber.effectTag & Incomplete) === NoEffect) {
13144 // Append all the effects of the subtree and this fiber onto the effect
13145 // list of the parent. The completion order of the children affects the
13146 // side-effect order.
13147 if (returnFiber.firstEffect === null) {
13148 returnFiber.firstEffect = workInProgress.firstEffect;
13149 }
13150 if (workInProgress.lastEffect !== null) {
13151 if (returnFiber.lastEffect !== null) {
13152 returnFiber.lastEffect.nextEffect = workInProgress.firstEffect;
13153 }
13154 returnFiber.lastEffect = workInProgress.lastEffect;
13155 }
13156
13157 // If this fiber had side-effects, we append it AFTER the children's
13158 // side-effects. We can perform certain side-effects earlier if
13159 // needed, by doing multiple passes over the effect list. We don't want
13160 // to schedule our own side-effect on our own list because if end up
13161 // reusing children we'll schedule this effect onto itself since we're
13162 // 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