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

Function updateHostComponent

code/third-party/public/app.js:9249–9306  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

9247 }
9248
9249 function updateHostComponent(current, workInProgress, renderExpirationTime) {
9250 pushHostContext(workInProgress);
9251
9252 if (current === null) {
9253 tryToClaimNextHydratableInstance(workInProgress);
9254 }
9255
9256 var type = workInProgress.type;
9257 var memoizedProps = workInProgress.memoizedProps;
9258 var nextProps = workInProgress.pendingProps;
9259 var prevProps = current !== null ? current.memoizedProps : null;
9260
9261 if (hasLegacyContextChanged()) {
9262 // Normally we can bail out on props equality but if context has changed
9263 // we don't do the bailout and we have to reuse existing props instead.
9264 } else if (memoizedProps === nextProps) {
9265 var isHidden = workInProgress.mode & AsyncMode && shouldDeprioritizeSubtree(type, nextProps);
9266 if (isHidden) {
9267 // Before bailing out, make sure we've deprioritized a hidden component.
9268 workInProgress.expirationTime = Never;
9269 }
9270 if (!isHidden || renderExpirationTime !== Never) {
9271 return bailoutOnAlreadyFinishedWork(current, workInProgress);
9272 }
9273 // If we're rendering a hidden node at hidden priority, don't bailout. The
9274 // parent is complete, but the children may not be.
9275 }
9276
9277 var nextChildren = nextProps.children;
9278 var isDirectTextChild = shouldSetTextContent(type, nextProps);
9279
9280 if (isDirectTextChild) {
9281 // We special case a direct text child of a host node. This is a common
9282 // case. We won't handle it as a reified child. We will instead handle
9283 // this in the host environment that also have access to this prop. That
9284 // avoids allocating another HostText fiber and traversing it.
9285 nextChildren = null;
9286 } else if (prevProps && shouldSetTextContent(type, prevProps)) {
9287 // If we're switching from a direct text child to a normal child, or to
9288 // empty, we need to schedule the text content to be reset.
9289 workInProgress.effectTag |= ContentReset;
9290 }
9291
9292 markRef(current, workInProgress);
9293
9294 // Check the host config to see if the children are offscreen/hidden.
9295 if (renderExpirationTime !== Never && workInProgress.mode & AsyncMode && shouldDeprioritizeSubtree(type, nextProps)) {
9296 // Down-prioritize the children.
9297 workInProgress.expirationTime = Never;
9298 // Bailout and come back to this fiber later.
9299 workInProgress.memoizedProps = nextProps;
9300 return null;
9301 }
9302
9303 reconcileChildren(current, workInProgress, nextChildren);
9304 memoizeProps(workInProgress, nextProps);
9305 return workInProgress.child;
9306 }

Callers 2

beginWorkFunction · 0.70
completeWorkFunction · 0.70

Calls 6

pushHostContextFunction · 0.70
markRefFunction · 0.70
reconcileChildrenFunction · 0.70
memoizePropsFunction · 0.70

Tested by

no test coverage detected