MCPcopy Create free account
hub / github.com/reactjs/react-rails / createWorkInProgress

Function createWorkInProgress

lib/assets/react-source/development/react.js:27388–27480  ·  view source on GitHub ↗
(current, pendingProps)

Source from the content-addressed store, hash-verified

27386 } // This is used to create an alternate fiber to do work on.
27387
27388 function createWorkInProgress(current, pendingProps) {
27389 var workInProgress = current.alternate;
27390
27391 if (workInProgress === null) {
27392 // We use a double buffering pooling technique because we know that we'll
27393 // only ever need at most two versions of a tree. We pool the "other" unused
27394 // node that we're free to reuse. This is lazily created to avoid allocating
27395 // extra objects for things that are never updated. It also allow us to
27396 // reclaim the extra memory if needed.
27397 workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode);
27398 workInProgress.elementType = current.elementType;
27399 workInProgress.type = current.type;
27400 workInProgress.stateNode = current.stateNode;
27401
27402 {
27403 // DEV-only fields
27404 {
27405 workInProgress._debugID = current._debugID;
27406 }
27407
27408 workInProgress._debugSource = current._debugSource;
27409 workInProgress._debugOwner = current._debugOwner;
27410 workInProgress._debugHookTypes = current._debugHookTypes;
27411 }
27412
27413 workInProgress.alternate = current;
27414 current.alternate = workInProgress;
27415 } else {
27416 workInProgress.pendingProps = pendingProps; // We already have an alternate.
27417 // Reset the effect tag.
27418
27419 workInProgress.effectTag = NoEffect; // The effect list is no longer valid.
27420
27421 workInProgress.nextEffect = null;
27422 workInProgress.firstEffect = null;
27423 workInProgress.lastEffect = null;
27424
27425 {
27426 // We intentionally reset, rather than copy, actualDuration & actualStartTime.
27427 // This prevents time from endlessly accumulating in new commits.
27428 // This has the downside of resetting values for different priority renders,
27429 // But works for yielding (the common case) and should support resuming.
27430 workInProgress.actualDuration = 0;
27431 workInProgress.actualStartTime = -1;
27432 }
27433 }
27434
27435 workInProgress.childExpirationTime = current.childExpirationTime;
27436 workInProgress.expirationTime = current.expirationTime;
27437 workInProgress.child = current.child;
27438 workInProgress.memoizedProps = current.memoizedProps;
27439 workInProgress.memoizedState = current.memoizedState;
27440 workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so
27441 // it cannot be shared with the current fiber.
27442
27443 var currentDependencies = current.dependencies;
27444 workInProgress.dependencies = currentDependencies === null ? null : {
27445 expirationTime: currentDependencies.expirationTime,

Callers 5

useFiberFunction · 0.85
cloneChildFibersFunction · 0.85
updateMemoComponentFunction · 0.85
updateSuspenseComponentFunction · 0.85
prepareFreshStackFunction · 0.85

Calls 4

createFiberFunction · 0.85

Tested by

no test coverage detected