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

Function updateHostRoot

code/communication/public/app.js:9999–10049  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

9997 }
9998
9999 function updateHostRoot(current, workInProgress, renderExpirationTime) {
10000 pushHostRootContext(workInProgress);
10001 var updateQueue = workInProgress.updateQueue;
10002 if (updateQueue !== null) {
10003 var prevState = workInProgress.memoizedState;
10004 var state = processUpdateQueue(current, workInProgress, updateQueue, null, null, renderExpirationTime);
10005 memoizeState(workInProgress, state);
10006 updateQueue = workInProgress.updateQueue;
10007
10008 var element = void 0;
10009 if (updateQueue !== null && updateQueue.capturedValues !== null) {
10010 // There's an uncaught error. Unmount the whole root.
10011 element = null;
10012 } else if (prevState === state) {
10013 // If the state is the same as before, that's a bailout because we had
10014 // no work that expires at this time.
10015 resetHydrationState();
10016 return bailoutOnAlreadyFinishedWork(current, workInProgress);
10017 } else {
10018 element = state.element;
10019 }
10020 var root = workInProgress.stateNode;
10021 if ((current === null || current.child === null) && root.hydrate && enterHydrationState(workInProgress)) {
10022 // If we don't have any current children this might be the first pass.
10023 // We always try to hydrate. If this isn't a hydration pass there won't
10024 // be any children to hydrate which is effectively the same thing as
10025 // not hydrating.
10026
10027 // This is a bit of a hack. We track the host root as a placement to
10028 // know that we're currently in a mounting state. That way isMounted
10029 // works as expected. We must reset this before committing.
10030 // TODO: Delete this when we delete isMounted and findDOMNode.
10031 workInProgress.effectTag |= Placement;
10032
10033 // Ensure that children mount into this root without tracking
10034 // side-effects. This ensures that we don't store Placement effects on
10035 // nodes that will be hydrated.
10036 workInProgress.child = mountChildFibers(workInProgress, null, element, renderExpirationTime);
10037 } else {
10038 // Otherwise reset hydration state in case we aborted and resumed another
10039 // root.
10040 resetHydrationState();
10041 reconcileChildren(current, workInProgress, element);
10042 }
10043 memoizeState(workInProgress, state);
10044 return workInProgress.child;
10045 }
10046 resetHydrationState();
10047 // If there is no update queue, that's a bailout because the root has no props.
10048 return bailoutOnAlreadyFinishedWork(current, workInProgress);
10049 }
10050
10051 function updateHostComponent(current, workInProgress, renderExpirationTime) {
10052 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