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

Function createWorkInProgress

code/new-context-api/public/app.js:6262–6309  ·  view source on GitHub ↗
(current, pendingProps, expirationTime)

Source from the content-addressed store, hash-verified

6260
6261// This is used to create an alternate fiber to do work on.
6262function createWorkInProgress(current, pendingProps, expirationTime) {
6263 var workInProgress = current.alternate;
6264 if (workInProgress === null) {
6265 // We use a double buffering pooling technique because we know that we'll
6266 // only ever need at most two versions of a tree. We pool the "other" unused
6267 // node that we're free to reuse. This is lazily created to avoid allocating
6268 // extra objects for things that are never updated. It also allow us to
6269 // reclaim the extra memory if needed.
6270 workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode);
6271 workInProgress.type = current.type;
6272 workInProgress.stateNode = current.stateNode;
6273
6274 {
6275 // DEV-only fields
6276 workInProgress._debugID = current._debugID;
6277 workInProgress._debugSource = current._debugSource;
6278 workInProgress._debugOwner = current._debugOwner;
6279 }
6280
6281 workInProgress.alternate = current;
6282 current.alternate = workInProgress;
6283 } else {
6284 workInProgress.pendingProps = pendingProps;
6285
6286 // We already have an alternate.
6287 // Reset the effect tag.
6288 workInProgress.effectTag = NoEffect;
6289
6290 // The effect list is no longer valid.
6291 workInProgress.nextEffect = null;
6292 workInProgress.firstEffect = null;
6293 workInProgress.lastEffect = null;
6294 }
6295
6296 workInProgress.expirationTime = expirationTime;
6297
6298 workInProgress.child = current.child;
6299 workInProgress.memoizedProps = current.memoizedProps;
6300 workInProgress.memoizedState = current.memoizedState;
6301 workInProgress.updateQueue = current.updateQueue;
6302
6303 // These will be overridden during the parent's reconciliation
6304 workInProgress.sibling = current.sibling;
6305 workInProgress.index = current.index;
6306 workInProgress.ref = current.ref;
6307
6308 return workInProgress;
6309}
6310
6311function createHostRootFiber(isAsync) {
6312 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