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

Function updateHostRoot

code/third-party/public/app.js:9197–9247  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

9195 }
9196
9197 function updateHostRoot(current, workInProgress, renderExpirationTime) {
9198 pushHostRootContext(workInProgress);
9199 var updateQueue = workInProgress.updateQueue;
9200 if (updateQueue !== null) {
9201 var prevState = workInProgress.memoizedState;
9202 var state = processUpdateQueue(current, workInProgress, updateQueue, null, null, renderExpirationTime);
9203 memoizeState(workInProgress, state);
9204 updateQueue = workInProgress.updateQueue;
9205
9206 var element = void 0;
9207 if (updateQueue !== null && updateQueue.capturedValues !== null) {
9208 // There's an uncaught error. Unmount the whole root.
9209 element = null;
9210 } else if (prevState === state) {
9211 // If the state is the same as before, that's a bailout because we had
9212 // no work that expires at this time.
9213 resetHydrationState();
9214 return bailoutOnAlreadyFinishedWork(current, workInProgress);
9215 } else {
9216 element = state.element;
9217 }
9218 var root = workInProgress.stateNode;
9219 if ((current === null || current.child === null) && root.hydrate && enterHydrationState(workInProgress)) {
9220 // If we don't have any current children this might be the first pass.
9221 // We always try to hydrate. If this isn't a hydration pass there won't
9222 // be any children to hydrate which is effectively the same thing as
9223 // not hydrating.
9224
9225 // This is a bit of a hack. We track the host root as a placement to
9226 // know that we're currently in a mounting state. That way isMounted
9227 // works as expected. We must reset this before committing.
9228 // TODO: Delete this when we delete isMounted and findDOMNode.
9229 workInProgress.effectTag |= Placement;
9230
9231 // Ensure that children mount into this root without tracking
9232 // side-effects. This ensures that we don't store Placement effects on
9233 // nodes that will be hydrated.
9234 workInProgress.child = mountChildFibers(workInProgress, null, element, renderExpirationTime);
9235 } else {
9236 // Otherwise reset hydration state in case we aborted and resumed another
9237 // root.
9238 resetHydrationState();
9239 reconcileChildren(current, workInProgress, element);
9240 }
9241 memoizeState(workInProgress, state);
9242 return workInProgress.child;
9243 }
9244 resetHydrationState();
9245 // If there is no update queue, that's a bailout because the root has no props.
9246 return bailoutOnAlreadyFinishedWork(current, workInProgress);
9247 }
9248
9249 function updateHostComponent(current, workInProgress, renderExpirationTime) {
9250 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