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

Function completeWork

code/controlled-uncontrolled/public/app.js:10124–10300  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

10122 }
10123
10124 function completeWork(current, workInProgress, renderExpirationTime) {
10125 var newProps = workInProgress.pendingProps;
10126 switch (workInProgress.tag) {
10127 case FunctionalComponent:
10128 return null;
10129 case ClassComponent:
10130 {
10131 // We are leaving this subtree, so pop context if any.
10132 popLegacyContextProvider(workInProgress);
10133
10134 // If this component caught an error, schedule an error log effect.
10135 var instance = workInProgress.stateNode;
10136 var updateQueue = workInProgress.updateQueue;
10137 if (updateQueue !== null && updateQueue.capturedValues !== null) {
10138 workInProgress.effectTag &= ~DidCapture;
10139 if (typeof instance.componentDidCatch === 'function') {
10140 workInProgress.effectTag |= ErrLog;
10141 } else {
10142 // Normally we clear this in the commit phase, but since we did not
10143 // schedule an effect, we need to reset it here.
10144 updateQueue.capturedValues = null;
10145 }
10146 }
10147 return null;
10148 }
10149 case HostRoot:
10150 {
10151 popHostContainer(workInProgress);
10152 popTopLevelLegacyContextObject(workInProgress);
10153 var fiberRoot = workInProgress.stateNode;
10154 if (fiberRoot.pendingContext) {
10155 fiberRoot.context = fiberRoot.pendingContext;
10156 fiberRoot.pendingContext = null;
10157 }
10158 if (current === null || current.child === null) {
10159 // If we hydrated, pop so that we can delete any remaining children
10160 // that weren't hydrated.
10161 popHydrationState(workInProgress);
10162 // This resets the hacky state to fix isMounted before committing.
10163 // TODO: Delete this when we delete isMounted and findDOMNode.
10164 workInProgress.effectTag &= ~Placement;
10165 }
10166 updateHostContainer(workInProgress);
10167
10168 var _updateQueue = workInProgress.updateQueue;
10169 if (_updateQueue !== null && _updateQueue.capturedValues !== null) {
10170 workInProgress.effectTag |= ErrLog;
10171 }
10172 return null;
10173 }
10174 case HostComponent:
10175 {
10176 popHostContext(workInProgress);
10177 var rootContainerInstance = getRootHostContainer();
10178 var type = workInProgress.type;
10179 if (current !== null && workInProgress.stateNode != null) {
10180 // If we have an alternate, that means this is an update and we need to
10181 // schedule a side-effect to do the updates.

Callers 1

completeUnitOfWorkFunction · 0.70

Calls 15

popHostContainerFunction · 0.70
popHydrationStateFunction · 0.70
popHostContextFunction · 0.70
getRootHostContainerFunction · 0.70
getHostContextFunction · 0.70
updateHostComponentFunction · 0.70
markRefFunction · 0.70
invariantFunction · 0.70
markUpdateFunction · 0.70
appendAllChildrenFunction · 0.70
updateHostTextFunction · 0.70

Tested by

no test coverage detected