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

Function updateHostRoot

code/controlled-uncontrolled/public/app.js:9288–9338  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

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