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

Function createWorkInProgress

code/event-handlers/public/app.js:6231–6278  ·  view source on GitHub ↗
(current, pendingProps, expirationTime)

Source from the content-addressed store, hash-verified

6229
6230// This is used to create an alternate fiber to do work on.
6231function createWorkInProgress(current, pendingProps, expirationTime) {
6232 var workInProgress = current.alternate;
6233 if (workInProgress === null) {
6234 // We use a double buffering pooling technique because we know that we'll
6235 // only ever need at most two versions of a tree. We pool the "other" unused
6236 // node that we're free to reuse. This is lazily created to avoid allocating
6237 // extra objects for things that are never updated. It also allow us to
6238 // reclaim the extra memory if needed.
6239 workInProgress = createFiber(current.tag, pendingProps, current.key, current.mode);
6240 workInProgress.type = current.type;
6241 workInProgress.stateNode = current.stateNode;
6242
6243 {
6244 // DEV-only fields
6245 workInProgress._debugID = current._debugID;
6246 workInProgress._debugSource = current._debugSource;
6247 workInProgress._debugOwner = current._debugOwner;
6248 }
6249
6250 workInProgress.alternate = current;
6251 current.alternate = workInProgress;
6252 } else {
6253 workInProgress.pendingProps = pendingProps;
6254
6255 // We already have an alternate.
6256 // Reset the effect tag.
6257 workInProgress.effectTag = NoEffect;
6258
6259 // The effect list is no longer valid.
6260 workInProgress.nextEffect = null;
6261 workInProgress.firstEffect = null;
6262 workInProgress.lastEffect = null;
6263 }
6264
6265 workInProgress.expirationTime = expirationTime;
6266
6267 workInProgress.child = current.child;
6268 workInProgress.memoizedProps = current.memoizedProps;
6269 workInProgress.memoizedState = current.memoizedState;
6270 workInProgress.updateQueue = current.updateQueue;
6271
6272 // These will be overridden during the parent's reconciliation
6273 workInProgress.sibling = current.sibling;
6274 workInProgress.index = current.index;
6275 workInProgress.ref = current.ref;
6276
6277 return workInProgress;
6278}
6279
6280function createHostRootFiber(isAsync) {
6281 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