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

Function updateHostRoot

code/new-context-api/public/app.js:9325–9375  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

9323 }
9324
9325 function updateHostRoot(current, workInProgress, renderExpirationTime) {
9326 pushHostRootContext(workInProgress);
9327 var updateQueue = workInProgress.updateQueue;
9328 if (updateQueue !== null) {
9329 var prevState = workInProgress.memoizedState;
9330 var state = processUpdateQueue(current, workInProgress, updateQueue, null, null, renderExpirationTime);
9331 memoizeState(workInProgress, state);
9332 updateQueue = workInProgress.updateQueue;
9333
9334 var element = void 0;
9335 if (updateQueue !== null && updateQueue.capturedValues !== null) {
9336 // There's an uncaught error. Unmount the whole root.
9337 element = null;
9338 } else if (prevState === state) {
9339 // If the state is the same as before, that's a bailout because we had
9340 // no work that expires at this time.
9341 resetHydrationState();
9342 return bailoutOnAlreadyFinishedWork(current, workInProgress);
9343 } else {
9344 element = state.element;
9345 }
9346 var root = workInProgress.stateNode;
9347 if ((current === null || current.child === null) && root.hydrate && enterHydrationState(workInProgress)) {
9348 // If we don't have any current children this might be the first pass.
9349 // We always try to hydrate. If this isn't a hydration pass there won't
9350 // be any children to hydrate which is effectively the same thing as
9351 // not hydrating.
9352
9353 // This is a bit of a hack. We track the host root as a placement to
9354 // know that we're currently in a mounting state. That way isMounted
9355 // works as expected. We must reset this before committing.
9356 // TODO: Delete this when we delete isMounted and findDOMNode.
9357 workInProgress.effectTag |= Placement;
9358
9359 // Ensure that children mount into this root without tracking
9360 // side-effects. This ensures that we don't store Placement effects on
9361 // nodes that will be hydrated.
9362 workInProgress.child = mountChildFibers(workInProgress, null, element, renderExpirationTime);
9363 } else {
9364 // Otherwise reset hydration state in case we aborted and resumed another
9365 // root.
9366 resetHydrationState();
9367 reconcileChildren(current, workInProgress, element);
9368 }
9369 memoizeState(workInProgress, state);
9370 return workInProgress.child;
9371 }
9372 resetHydrationState();
9373 // If there is no update queue, that's a bailout because the root has no props.
9374 return bailoutOnAlreadyFinishedWork(current, workInProgress);
9375 }
9376
9377 function updateHostComponent(current, workInProgress, renderExpirationTime) {
9378 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