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

Function performWorkOnRoot

code/communication/public/app.js:13847–13892  ·  view source on GitHub ↗
(root, expirationTime, isAsync)

Source from the content-addressed store, hash-verified

13845 }
13846
13847 function performWorkOnRoot(root, expirationTime, isAsync) {
13848 !!isRendering ? invariant(false, 'performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue.') : void 0;
13849
13850 isRendering = true;
13851
13852 // Check if this is async work or sync/expired work.
13853 if (!isAsync) {
13854 // Flush sync work.
13855 var finishedWork = root.finishedWork;
13856 if (finishedWork !== null) {
13857 // This root is already complete. We can commit it.
13858 completeRoot(root, finishedWork, expirationTime);
13859 } else {
13860 root.finishedWork = null;
13861 finishedWork = renderRoot(root, expirationTime, false);
13862 if (finishedWork !== null) {
13863 // We've completed the root. Commit it.
13864 completeRoot(root, finishedWork, expirationTime);
13865 }
13866 }
13867 } else {
13868 // Flush async work.
13869 var _finishedWork = root.finishedWork;
13870 if (_finishedWork !== null) {
13871 // This root is already complete. We can commit it.
13872 completeRoot(root, _finishedWork, expirationTime);
13873 } else {
13874 root.finishedWork = null;
13875 _finishedWork = renderRoot(root, expirationTime, true);
13876 if (_finishedWork !== null) {
13877 // We've completed the root. Check the deadline one more time
13878 // before committing.
13879 if (!shouldYield()) {
13880 // Still time left. Commit the root.
13881 completeRoot(root, _finishedWork, expirationTime);
13882 } else {
13883 // There's no time left. Mark this root as complete. We'll come
13884 // back and commit it later.
13885 root.finishedWork = _finishedWork;
13886 }
13887 }
13888 }
13889 }
13890
13891 isRendering = false;
13892 }
13893
13894 function completeRoot(root, finishedWork, expirationTime) {
13895 // 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