MCPcopy Create free account
hub / github.com/microsoft/SandDance / resetWorkInProgress

Function resetWorkInProgress

docs/external/js/react-dom.development.js:23922–23980  ·  view source on GitHub ↗
(workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

23920 } // Used to reuse a Fiber for a second pass.
23921
23922 function resetWorkInProgress(workInProgress, renderExpirationTime) {
23923 // This resets the Fiber to what createFiber or createWorkInProgress would
23924 // have set the values to before during the first pass. Ideally this wouldn't
23925 // be necessary but unfortunately many code paths reads from the workInProgress
23926 // when they should be reading from current and writing to workInProgress.
23927 // We assume pendingProps, index, key, ref, return are still untouched to
23928 // avoid doing another reconciliation.
23929 // Reset the effect tag but keep any Placement tags, since that's something
23930 // that child fiber is setting, not the reconciliation.
23931 workInProgress.effectTag &= Placement; // The effect list is no longer valid.
23932
23933 workInProgress.nextEffect = null;
23934 workInProgress.firstEffect = null;
23935 workInProgress.lastEffect = null;
23936 var current = workInProgress.alternate;
23937
23938 if (current === null) {
23939 // Reset to createFiber's initial values.
23940 workInProgress.childExpirationTime = NoWork;
23941 workInProgress.expirationTime = renderExpirationTime;
23942 workInProgress.child = null;
23943 workInProgress.memoizedProps = null;
23944 workInProgress.memoizedState = null;
23945 workInProgress.updateQueue = null;
23946 workInProgress.dependencies = null;
23947
23948 {
23949 // Note: We don't reset the actualTime counts. It's useful to accumulate
23950 // actual time across multiple render passes.
23951 workInProgress.selfBaseDuration = 0;
23952 workInProgress.treeBaseDuration = 0;
23953 }
23954 } else {
23955 // Reset to the cloned values that createWorkInProgress would've.
23956 workInProgress.childExpirationTime = current.childExpirationTime;
23957 workInProgress.expirationTime = current.expirationTime;
23958 workInProgress.child = current.child;
23959 workInProgress.memoizedProps = current.memoizedProps;
23960 workInProgress.memoizedState = current.memoizedState;
23961 workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so
23962 // it cannot be shared with the current fiber.
23963
23964 var currentDependencies = current.dependencies;
23965 workInProgress.dependencies = currentDependencies === null ? null : {
23966 expirationTime: currentDependencies.expirationTime,
23967 firstContext: currentDependencies.firstContext,
23968 responders: currentDependencies.responders
23969 };
23970
23971 {
23972 // Note: We don't reset the actualTime counts. It's useful to accumulate
23973 // actual time across multiple render passes.
23974 workInProgress.selfBaseDuration = current.selfBaseDuration;
23975 workInProgress.treeBaseDuration = current.treeBaseDuration;
23976 }
23977 }
23978
23979 return workInProgress;

Callers 1

resetChildFibersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected