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

Function updateHostRoot

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

Source from the content-addressed store, hash-verified

17340 }
17341
17342 function updateHostRoot(current, workInProgress, renderExpirationTime) {
17343 pushHostRootContext(workInProgress);
17344 var updateQueue = workInProgress.updateQueue;
17345
17346 if (!(current !== null && updateQueue !== null)) {
17347 {
17348 throw Error( "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." );
17349 }
17350 }
17351
17352 var nextProps = workInProgress.pendingProps;
17353 var prevState = workInProgress.memoizedState;
17354 var prevChildren = prevState !== null ? prevState.element : null;
17355 cloneUpdateQueue(current, workInProgress);
17356 processUpdateQueue(workInProgress, nextProps, null, renderExpirationTime);
17357 var nextState = workInProgress.memoizedState; // Caution: React DevTools currently depends on this property
17358 // being called "element".
17359
17360 var nextChildren = nextState.element;
17361
17362 if (nextChildren === prevChildren) {
17363 // If the state is the same as before, that's a bailout because we had
17364 // no work that expires at this time.
17365 resetHydrationState();
17366 return bailoutOnAlreadyFinishedWork(current, workInProgress, renderExpirationTime);
17367 }
17368
17369 var root = workInProgress.stateNode;
17370
17371 if (root.hydrate && enterHydrationState(workInProgress)) {
17372 // If we don't have any current children this might be the first pass.
17373 // We always try to hydrate. If this isn't a hydration pass there won't
17374 // be any children to hydrate which is effectively the same thing as
17375 // not hydrating.
17376 var child = mountChildFibers(workInProgress, null, nextChildren, renderExpirationTime);
17377 workInProgress.child = child;
17378 var node = child;
17379
17380 while (node) {
17381 // Mark each child as hydrating. This is a fast path to know whether this
17382 // tree is part of a hydrating tree. This is used to determine if a child
17383 // node has fully mounted yet, and for scheduling event replaying.
17384 // Conceptually this is similar to Placement in that a new subtree is
17385 // inserted into the React tree here. It just happens to not need DOM
17386 // mutations because it already exists.
17387 node.effectTag = node.effectTag & ~Placement | Hydrating;
17388 node = node.sibling;
17389 }
17390 } else {
17391 // Otherwise reset hydration state in case we aborted and resumed another
17392 // root.
17393 reconcileChildren(current, workInProgress, nextChildren, renderExpirationTime);
17394 resetHydrationState();
17395 }
17396
17397 return workInProgress.child;
17398 }
17399

Callers 1

beginWorkFunction · 0.85

Calls 7

pushHostRootContextFunction · 0.85
cloneUpdateQueueFunction · 0.85
processUpdateQueueFunction · 0.85
resetHydrationStateFunction · 0.85
enterHydrationStateFunction · 0.85
reconcileChildrenFunction · 0.85

Tested by

no test coverage detected