MCPcopy Create free account
hub / github.com/danielstocks/react-sortable / commitAllWork

Function commitAllWork

bundle.js:7731–7759  ·  view source on GitHub ↗
(finishedWork)

Source from the content-addressed store, hash-verified

7729nextEffect.nextEffect=null;// Ensure that we reset the effectTag here so that we can rely on effect
7730// tags to reason about the current life-cycle.
7731nextEffect=next;}}function commitAllWork(finishedWork){// We keep track of this so that captureError can collect any boundaries
7732// that capture an error during the commit phase. The reason these aren't
7733// local to this function is because errors that occur during cWU are
7734// captured elsewhere, to prevent the unmount from being interrupted.
7735isCommitting=true;{startCommitTimer();}pendingCommit=null;var root=finishedWork.stateNode;!(root.current!==finishedWork)?invariant(false,'Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue.'):void 0;if(nextPriorityLevel===SynchronousPriority$1||nextPriorityLevel===TaskPriority$1){// Keep track of the number of iterations to prevent an infinite
7736// update loop.
7737nestedUpdateCount++;}// Reset this to null before calling lifecycles
7738ReactCurrentOwner$1.current=null;var firstEffect=void 0;if(finishedWork.effectTag>PerformedWork){// A fiber's effect list consists only of its children, not itself. So if
7739// the root has an effect, we need to add it to the end of the list. The
7740// resulting list is the set that would belong to the root's parent, if
7741// it had one; that is, all the effects in the tree including the root.
7742if(finishedWork.lastEffect!==null){finishedWork.lastEffect.nextEffect=finishedWork;firstEffect=finishedWork.firstEffect;}else{firstEffect=finishedWork;}}else{// There is no effect on the root.
7743firstEffect=finishedWork.firstEffect;}prepareForCommit();// Commit all the side-effects within a tree. We'll do this in two passes.
7744// The first pass performs all the host insertions, updates, deletions and
7745// ref unmounts.
7746nextEffect=firstEffect;{startCommitHostEffectsTimer();}while(nextEffect!==null){var didError=false;var _error=void 0;{invokeGuardedCallback$1(null,commitAllHostEffects,null);if(hasCaughtError()){didError=true;_error=clearCaughtError();}}if(didError){!(nextEffect!==null)?invariant(false,'Should have next effect. This error is likely caused by a bug in React. Please file an issue.'):void 0;captureError(nextEffect,_error);// Clean-up
7747if(nextEffect!==null){nextEffect=nextEffect.nextEffect;}}}{stopCommitHostEffectsTimer();}resetAfterCommit();// The work-in-progress tree is now the current tree. This must come after
7748// the first pass of the commit phase, so that the previous tree is still
7749// current during componentWillUnmount, but before the second pass, so that
7750// the finished work is current during componentDidMount/Update.
7751root.current=finishedWork;// In the second pass we'll perform all life-cycles and ref callbacks.
7752// Life-cycles happen as a separate pass so that all placements, updates,
7753// and deletions in the entire tree have already been invoked.
7754// This pass also triggers any renderer-specific initial effects.
7755nextEffect=firstEffect;{startCommitLifeCyclesTimer();}while(nextEffect!==null){var _didError=false;var _error2=void 0;{invokeGuardedCallback$1(null,commitAllLifeCycles,null);if(hasCaughtError()){_didError=true;_error2=clearCaughtError();}}if(_didError){!(nextEffect!==null)?invariant(false,'Should have next effect. This error is likely caused by a bug in React. Please file an issue.'):void 0;captureError(nextEffect,_error2);if(nextEffect!==null){nextEffect=nextEffect.nextEffect;}}}isCommitting=false;{stopCommitLifeCyclesTimer();stopCommitTimer();}if(typeof onCommitRoot==='function'){onCommitRoot(finishedWork.stateNode);}if(true&&ReactFiberInstrumentation$1.debugTool){ReactFiberInstrumentation$1.debugTool.onCommitWork(finishedWork);}// If we caught any errors during this commit, schedule their boundaries
7756// to update.
7757if(commitPhaseBoundaries){commitPhaseBoundaries.forEach(scheduleErrorRecovery);commitPhaseBoundaries=null;}// This tree is done. Reset the unit of work pointer to the next highest
7758// priority root. If there's no more work left, the pointer is set to null.
7759resetNextUnitOfWork();}function resetWorkPriority(workInProgress,renderPriority){if(workInProgress.pendingWorkPriority!==NoWork$2&&workInProgress.pendingWorkPriority>renderPriority){// This was a down-prioritization. Don't bubble priority from children.
7760return;}// Check for pending update priority.
7761var newPriority=getUpdatePriority$1(workInProgress);// TODO: Coroutines need to visit stateNode
7762var child=workInProgress.child;while(child!==null){// Ensure that remaining work priority bubbles up.

Callers 2

handleCommitPhaseErrorsFunction · 0.85
workLoopFunction · 0.85

Calls 3

captureErrorFunction · 0.85
resetNextUnitOfWorkFunction · 0.85
invariantFunction · 0.70

Tested by

no test coverage detected