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

Function updateHostRoot

code/higher-order-components/public/app.js:9958–10008  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

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