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

Function createWorkInProgress

code/styling/public/app.js:6901–6948  ·  view source on GitHub ↗
(current, pendingProps, expirationTime)

Source from the content-addressed store, hash-verified

6899
6900// This is used to create an alternate fiber to do work on.
6901function createWorkInProgress(current, pendingProps, expirationTime) {
6902 var workInProgress = current.alternate;
6903 if (workInProgress === null) {
6904 // We use a double buffering pooling technique because we know that we'll
6905 // only ever need at most two versions of a tree. We pool the "other" unused
6906 // node that we're free to reuse. This is lazily created to avoid allocating
6907 // extra objects for things that are never updated. It also allow us to
6908 // reclaim the extra memory if needed.
6909 workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode);
6910 workInProgress.type = current.type;
6911 workInProgress.stateNode = current.stateNode;
6912
6913 {
6914 // DEV-only fields
6915 workInProgress._debugID = current._debugID;
6916 workInProgress._debugSource = current._debugSource;
6917 workInProgress._debugOwner = current._debugOwner;
6918 }
6919
6920 workInProgress.alternate = current;
6921 current.alternate = workInProgress;
6922 } else {
6923 workInProgress.pendingProps = pendingProps;
6924
6925 // We already have an alternate.
6926 // Reset the effect tag.
6927 workInProgress.effectTag = NoEffect;
6928
6929 // The effect list is no longer valid.
6930 workInProgress.nextEffect = null;
6931 workInProgress.firstEffect = null;
6932 workInProgress.lastEffect = null;
6933 }
6934
6935 workInProgress.expirationTime = expirationTime;
6936
6937 workInProgress.child = current.child;
6938 workInProgress.memoizedProps = current.memoizedProps;
6939 workInProgress.memoizedState = current.memoizedState;
6940 workInProgress.updateQueue = current.updateQueue;
6941
6942 // These will be overridden during the parent's reconciliation
6943 workInProgress.sibling = current.sibling;
6944 workInProgress.index = current.index;
6945 workInProgress.ref = current.ref;
6946
6947 return workInProgress;
6948}
6949
6950function createHostRootFiber(isAsync) {
6951 var mode = isAsync ? AsyncMode | StrictMode : NoContext;

Callers 3

useFiberFunction · 0.70
cloneChildFibersFunction · 0.70
renderRootFunction · 0.70

Calls 1

createFiberFunction · 0.70

Tested by

no test coverage detected