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

Function updateHostRoot

code/dependency-injection/public/app.js:10057–10107  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

10055 }
10056
10057 function updateHostRoot(current, workInProgress, renderExpirationTime) {
10058 pushHostRootContext(workInProgress);
10059 var updateQueue = workInProgress.updateQueue;
10060 if (updateQueue !== null) {
10061 var prevState = workInProgress.memoizedState;
10062 var state = processUpdateQueue(current, workInProgress, updateQueue, null, null, renderExpirationTime);
10063 memoizeState(workInProgress, state);
10064 updateQueue = workInProgress.updateQueue;
10065
10066 var element = void 0;
10067 if (updateQueue !== null && updateQueue.capturedValues !== null) {
10068 // There's an uncaught error. Unmount the whole root.
10069 element = null;
10070 } else if (prevState === state) {
10071 // If the state is the same as before, that's a bailout because we had
10072 // no work that expires at this time.
10073 resetHydrationState();
10074 return bailoutOnAlreadyFinishedWork(current, workInProgress);
10075 } else {
10076 element = state.element;
10077 }
10078 var root = workInProgress.stateNode;
10079 if ((current === null || current.child === null) && root.hydrate && enterHydrationState(workInProgress)) {
10080 // If we don't have any current children this might be the first pass.
10081 // We always try to hydrate. If this isn't a hydration pass there won't
10082 // be any children to hydrate which is effectively the same thing as
10083 // not hydrating.
10084
10085 // This is a bit of a hack. We track the host root as a placement to
10086 // know that we're currently in a mounting state. That way isMounted
10087 // works as expected. We must reset this before committing.
10088 // TODO: Delete this when we delete isMounted and findDOMNode.
10089 workInProgress.effectTag |= Placement;
10090
10091 // Ensure that children mount into this root without tracking
10092 // side-effects. This ensures that we don't store Placement effects on
10093 // nodes that will be hydrated.
10094 workInProgress.child = mountChildFibers(workInProgress, null, element, renderExpirationTime);
10095 } else {
10096 // Otherwise reset hydration state in case we aborted and resumed another
10097 // root.
10098 resetHydrationState();
10099 reconcileChildren(current, workInProgress, element);
10100 }
10101 memoizeState(workInProgress, state);
10102 return workInProgress.child;
10103 }
10104 resetHydrationState();
10105 // If there is no update queue, that's a bailout because the root has no props.
10106 return bailoutOnAlreadyFinishedWork(current, workInProgress);
10107 }
10108
10109 function updateHostComponent(current, workInProgress, renderExpirationTime) {
10110 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