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

Function updateHostRoot

code/one-direction-data-flow/public/app.js:9837–9887  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

9835 }
9836
9837 function updateHostRoot(current, workInProgress, renderExpirationTime) {
9838 pushHostRootContext(workInProgress);
9839 var updateQueue = workInProgress.updateQueue;
9840 if (updateQueue !== null) {
9841 var prevState = workInProgress.memoizedState;
9842 var state = processUpdateQueue(current, workInProgress, updateQueue, null, null, renderExpirationTime);
9843 memoizeState(workInProgress, state);
9844 updateQueue = workInProgress.updateQueue;
9845
9846 var element = void 0;
9847 if (updateQueue !== null && updateQueue.capturedValues !== null) {
9848 // There's an uncaught error. Unmount the whole root.
9849 element = null;
9850 } else if (prevState === state) {
9851 // If the state is the same as before, that's a bailout because we had
9852 // no work that expires at this time.
9853 resetHydrationState();
9854 return bailoutOnAlreadyFinishedWork(current, workInProgress);
9855 } else {
9856 element = state.element;
9857 }
9858 var root = workInProgress.stateNode;
9859 if ((current === null || current.child === null) && root.hydrate && enterHydrationState(workInProgress)) {
9860 // If we don't have any current children this might be the first pass.
9861 // We always try to hydrate. If this isn't a hydration pass there won't
9862 // be any children to hydrate which is effectively the same thing as
9863 // not hydrating.
9864
9865 // This is a bit of a hack. We track the host root as a placement to
9866 // know that we're currently in a mounting state. That way isMounted
9867 // works as expected. We must reset this before committing.
9868 // TODO: Delete this when we delete isMounted and findDOMNode.
9869 workInProgress.effectTag |= Placement;
9870
9871 // Ensure that children mount into this root without tracking
9872 // side-effects. This ensures that we don't store Placement effects on
9873 // nodes that will be hydrated.
9874 workInProgress.child = mountChildFibers(workInProgress, null, element, renderExpirationTime);
9875 } else {
9876 // Otherwise reset hydration state in case we aborted and resumed another
9877 // root.
9878 resetHydrationState();
9879 reconcileChildren(current, workInProgress, element);
9880 }
9881 memoizeState(workInProgress, state);
9882 return workInProgress.child;
9883 }
9884 resetHydrationState();
9885 // If there is no update queue, that's a bailout because the root has no props.
9886 return bailoutOnAlreadyFinishedWork(current, workInProgress);
9887 }
9888
9889 function updateHostComponent(current, workInProgress, renderExpirationTime) {
9890 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