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

Function scheduleWorkImpl

code/new-context-api/public/app.js:12834–12881  ·  view source on GitHub ↗
(fiber, expirationTime, isErrorRecovery)

Source from the content-addressed store, hash-verified

12832 }
12833
12834 function scheduleWorkImpl(fiber, expirationTime, isErrorRecovery) {
12835 recordScheduleUpdate();
12836
12837 {
12838 if (!isErrorRecovery && fiber.tag === ClassComponent) {
12839 var instance = fiber.stateNode;
12840 warnAboutInvalidUpdates(instance);
12841 }
12842 }
12843
12844 var node = fiber;
12845 while (node !== null) {
12846 // Walk the parent path to the root and update each node's
12847 // expiration time.
12848 if (node.expirationTime === NoWork || node.expirationTime > expirationTime) {
12849 node.expirationTime = expirationTime;
12850 }
12851 if (node.alternate !== null) {
12852 if (node.alternate.expirationTime === NoWork || node.alternate.expirationTime > expirationTime) {
12853 node.alternate.expirationTime = expirationTime;
12854 }
12855 }
12856 if (node['return'] === null) {
12857 if (node.tag === HostRoot) {
12858 var root = node.stateNode;
12859 if (!isWorking && nextRenderExpirationTime !== NoWork && expirationTime < nextRenderExpirationTime) {
12860 // This is an interruption. (Used for performance tracking.)
12861 interruptedBy = fiber;
12862 resetStack();
12863 }
12864 if (nextRoot !== root || !isWorking) {
12865 requestWork(root, expirationTime);
12866 }
12867 if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
12868 invariant(false, 'Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.');
12869 }
12870 } else {
12871 {
12872 if (!isErrorRecovery && fiber.tag === ClassComponent) {
12873 warnAboutUpdateOnUnmounted(fiber);
12874 }
12875 }
12876 return;
12877 }
12878 }
12879 node = node['return'];
12880 }
12881 }
12882
12883 function recalculateCurrentTime() {
12884 // Subtract initial time so it fits inside 32bits

Callers 1

scheduleWorkFunction · 0.70

Calls 4

recordScheduleUpdateFunction · 0.70
resetStackFunction · 0.70
requestWorkFunction · 0.70
invariantFunction · 0.70

Tested by

no test coverage detected