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

Function performWorkOnRoot

code/higher-order-components/public/app.js:13806–13851  ·  view source on GitHub ↗
(root, expirationTime, isAsync)

Source from the content-addressed store, hash-verified

13804 }
13805
13806 function performWorkOnRoot(root, expirationTime, isAsync) {
13807 !!isRendering ? invariant(false, 'performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue.') : void 0;
13808
13809 isRendering = true;
13810
13811 // Check if this is async work or sync/expired work.
13812 if (!isAsync) {
13813 // Flush sync work.
13814 var finishedWork = root.finishedWork;
13815 if (finishedWork !== null) {
13816 // This root is already complete. We can commit it.
13817 completeRoot(root, finishedWork, expirationTime);
13818 } else {
13819 root.finishedWork = null;
13820 finishedWork = renderRoot(root, expirationTime, false);
13821 if (finishedWork !== null) {
13822 // We've completed the root. Commit it.
13823 completeRoot(root, finishedWork, expirationTime);
13824 }
13825 }
13826 } else {
13827 // Flush async work.
13828 var _finishedWork = root.finishedWork;
13829 if (_finishedWork !== null) {
13830 // This root is already complete. We can commit it.
13831 completeRoot(root, _finishedWork, expirationTime);
13832 } else {
13833 root.finishedWork = null;
13834 _finishedWork = renderRoot(root, expirationTime, true);
13835 if (_finishedWork !== null) {
13836 // We've completed the root. Check the deadline one more time
13837 // before committing.
13838 if (!shouldYield()) {
13839 // Still time left. Commit the root.
13840 completeRoot(root, _finishedWork, expirationTime);
13841 } else {
13842 // There's no time left. Mark this root as complete. We'll come
13843 // back and commit it later.
13844 root.finishedWork = _finishedWork;
13845 }
13846 }
13847 }
13848 }
13849
13850 isRendering = false;
13851 }
13852
13853 function completeRoot(root, finishedWork, expirationTime) {
13854 // 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