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

Function performWorkOnRoot

code/controlled-uncontrolled/public/app.js:13136–13181  ·  view source on GitHub ↗
(root, expirationTime, isAsync)

Source from the content-addressed store, hash-verified

13134 }
13135
13136 function performWorkOnRoot(root, expirationTime, isAsync) {
13137 !!isRendering ? invariant(false, 'performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue.') : void 0;
13138
13139 isRendering = true;
13140
13141 // Check if this is async work or sync/expired work.
13142 if (!isAsync) {
13143 // Flush sync work.
13144 var finishedWork = root.finishedWork;
13145 if (finishedWork !== null) {
13146 // This root is already complete. We can commit it.
13147 completeRoot(root, finishedWork, expirationTime);
13148 } else {
13149 root.finishedWork = null;
13150 finishedWork = renderRoot(root, expirationTime, false);
13151 if (finishedWork !== null) {
13152 // We've completed the root. Commit it.
13153 completeRoot(root, finishedWork, expirationTime);
13154 }
13155 }
13156 } else {
13157 // Flush async work.
13158 var _finishedWork = root.finishedWork;
13159 if (_finishedWork !== null) {
13160 // This root is already complete. We can commit it.
13161 completeRoot(root, _finishedWork, expirationTime);
13162 } else {
13163 root.finishedWork = null;
13164 _finishedWork = renderRoot(root, expirationTime, true);
13165 if (_finishedWork !== null) {
13166 // We've completed the root. Check the deadline one more time
13167 // before committing.
13168 if (!shouldYield()) {
13169 // Still time left. Commit the root.
13170 completeRoot(root, _finishedWork, expirationTime);
13171 } else {
13172 // There's no time left. Mark this root as complete. We'll come
13173 // back and commit it later.
13174 root.finishedWork = _finishedWork;
13175 }
13176 }
13177 }
13178 }
13179
13180 isRendering = false;
13181 }
13182
13183 function completeRoot(root, finishedWork, expirationTime) {
13184 // Check if there's a batch that matches this expiration time.

Callers 3

requestWorkFunction · 0.70
performWorkFunction · 0.70
flushRootFunction · 0.70

Calls 4

invariantFunction · 0.70
completeRootFunction · 0.70
renderRootFunction · 0.70
shouldYieldFunction · 0.70

Tested by

no test coverage detected