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

Function updateHostRoot

code/styling/public/app.js:9964–10014  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

9962 }
9963
9964 function updateHostRoot(current, workInProgress, renderExpirationTime) {
9965 pushHostRootContext(workInProgress);
9966 var updateQueue = workInProgress.updateQueue;
9967 if (updateQueue !== null) {
9968 var prevState = workInProgress.memoizedState;
9969 var state = processUpdateQueue(current, workInProgress, updateQueue, null, null, renderExpirationTime);
9970 memoizeState(workInProgress, state);
9971 updateQueue = workInProgress.updateQueue;
9972
9973 var element = void 0;
9974 if (updateQueue !== null && updateQueue.capturedValues !== null) {
9975 // There's an uncaught error. Unmount the whole root.
9976 element = null;
9977 } else if (prevState === state) {
9978 // If the state is the same as before, that's a bailout because we had
9979 // no work that expires at this time.
9980 resetHydrationState();
9981 return bailoutOnAlreadyFinishedWork(current, workInProgress);
9982 } else {
9983 element = state.element;
9984 }
9985 var root = workInProgress.stateNode;
9986 if ((current === null || current.child === null) && root.hydrate && enterHydrationState(workInProgress)) {
9987 // If we don't have any current children this might be the first pass.
9988 // We always try to hydrate. If this isn't a hydration pass there won't
9989 // be any children to hydrate which is effectively the same thing as
9990 // not hydrating.
9991
9992 // This is a bit of a hack. We track the host root as a placement to
9993 // know that we're currently in a mounting state. That way isMounted
9994 // works as expected. We must reset this before committing.
9995 // TODO: Delete this when we delete isMounted and findDOMNode.
9996 workInProgress.effectTag |= Placement;
9997
9998 // Ensure that children mount into this root without tracking
9999 // side-effects. This ensures that we don't store Placement effects on
10000 // nodes that will be hydrated.
10001 workInProgress.child = mountChildFibers(workInProgress, null, element, renderExpirationTime);
10002 } else {
10003 // Otherwise reset hydration state in case we aborted and resumed another
10004 // root.
10005 resetHydrationState();
10006 reconcileChildren(current, workInProgress, element);
10007 }
10008 memoizeState(workInProgress, state);
10009 return workInProgress.child;
10010 }
10011 resetHydrationState();
10012 // If there is no update queue, that's a bailout because the root has no props.
10013 return bailoutOnAlreadyFinishedWork(current, workInProgress);
10014 }
10015
10016 function updateHostComponent(current, workInProgress, renderExpirationTime) {
10017 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