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

Function updateHostRoot

code/event-handlers/public/app.js:9294–9344  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

9292 }
9293
9294 function updateHostRoot(current, workInProgress, renderExpirationTime) {
9295 pushHostRootContext(workInProgress);
9296 var updateQueue = workInProgress.updateQueue;
9297 if (updateQueue !== null) {
9298 var prevState = workInProgress.memoizedState;
9299 var state = processUpdateQueue(current, workInProgress, updateQueue, null, null, renderExpirationTime);
9300 memoizeState(workInProgress, state);
9301 updateQueue = workInProgress.updateQueue;
9302
9303 var element = void 0;
9304 if (updateQueue !== null && updateQueue.capturedValues !== null) {
9305 // There's an uncaught error. Unmount the whole root.
9306 element = null;
9307 } else if (prevState === state) {
9308 // If the state is the same as before, that's a bailout because we had
9309 // no work that expires at this time.
9310 resetHydrationState();
9311 return bailoutOnAlreadyFinishedWork(current, workInProgress);
9312 } else {
9313 element = state.element;
9314 }
9315 var root = workInProgress.stateNode;
9316 if ((current === null || current.child === null) && root.hydrate && enterHydrationState(workInProgress)) {
9317 // If we don't have any current children this might be the first pass.
9318 // We always try to hydrate. If this isn't a hydration pass there won't
9319 // be any children to hydrate which is effectively the same thing as
9320 // not hydrating.
9321
9322 // This is a bit of a hack. We track the host root as a placement to
9323 // know that we're currently in a mounting state. That way isMounted
9324 // works as expected. We must reset this before committing.
9325 // TODO: Delete this when we delete isMounted and findDOMNode.
9326 workInProgress.effectTag |= Placement;
9327
9328 // Ensure that children mount into this root without tracking
9329 // side-effects. This ensures that we don't store Placement effects on
9330 // nodes that will be hydrated.
9331 workInProgress.child = mountChildFibers(workInProgress, null, element, renderExpirationTime);
9332 } else {
9333 // Otherwise reset hydration state in case we aborted and resumed another
9334 // root.
9335 resetHydrationState();
9336 reconcileChildren(current, workInProgress, element);
9337 }
9338 memoizeState(workInProgress, state);
9339 return workInProgress.child;
9340 }
9341 resetHydrationState();
9342 // If there is no update queue, that's a bailout because the root has no props.
9343 return bailoutOnAlreadyFinishedWork(current, workInProgress);
9344 }
9345
9346 function updateHostComponent(current, workInProgress, renderExpirationTime) {
9347 pushHostContext(workInProgress);

Callers 1

beginWorkFunction · 0.70

Calls 7

pushHostRootContextFunction · 0.70
processUpdateQueueFunction · 0.70
memoizeStateFunction · 0.70
resetHydrationStateFunction · 0.70
enterHydrationStateFunction · 0.70
reconcileChildrenFunction · 0.70

Tested by

no test coverage detected