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

Function completeUnitOfWork

code/higher-order-components/public/app.js:13064–13208  ·  view source on GitHub ↗
(workInProgress)

Source from the content-addressed store, hash-verified

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