MCPcopy Index your code
hub / github.com/krasimir/react-in-patterns / updateHostComponent

Function updateHostComponent

code/new-context-api/public/app.js:9377–9434  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

9375 }
9376
9377 function updateHostComponent(current, workInProgress, renderExpirationTime) {
9378 pushHostContext(workInProgress);
9379
9380 if (current === null) {
9381 tryToClaimNextHydratableInstance(workInProgress);
9382 }
9383
9384 var type = workInProgress.type;
9385 var memoizedProps = workInProgress.memoizedProps;
9386 var nextProps = workInProgress.pendingProps;
9387 var prevProps = current !== null ? current.memoizedProps : null;
9388
9389 if (hasLegacyContextChanged()) {
9390 // Normally we can bail out on props equality but if context has changed
9391 // we don't do the bailout and we have to reuse existing props instead.
9392 } else if (memoizedProps === nextProps) {
9393 var isHidden = workInProgress.mode & AsyncMode && shouldDeprioritizeSubtree(type, nextProps);
9394 if (isHidden) {
9395 // Before bailing out, make sure we've deprioritized a hidden component.
9396 workInProgress.expirationTime = Never;
9397 }
9398 if (!isHidden || renderExpirationTime !== Never) {
9399 return bailoutOnAlreadyFinishedWork(current, workInProgress);
9400 }
9401 // If we're rendering a hidden node at hidden priority, don't bailout. The
9402 // parent is complete, but the children may not be.
9403 }
9404
9405 var nextChildren = nextProps.children;
9406 var isDirectTextChild = shouldSetTextContent(type, nextProps);
9407
9408 if (isDirectTextChild) {
9409 // We special case a direct text child of a host node. This is a common
9410 // case. We won't handle it as a reified child. We will instead handle
9411 // this in the host environment that also have access to this prop. That
9412 // avoids allocating another HostText fiber and traversing it.
9413 nextChildren = null;
9414 } else if (prevProps && shouldSetTextContent(type, prevProps)) {
9415 // If we're switching from a direct text child to a normal child, or to
9416 // empty, we need to schedule the text content to be reset.
9417 workInProgress.effectTag |= ContentReset;
9418 }
9419
9420 markRef(current, workInProgress);
9421
9422 // Check the host config to see if the children are offscreen/hidden.
9423 if (renderExpirationTime !== Never && workInProgress.mode & AsyncMode && shouldDeprioritizeSubtree(type, nextProps)) {
9424 // Down-prioritize the children.
9425 workInProgress.expirationTime = Never;
9426 // Bailout and come back to this fiber later.
9427 workInProgress.memoizedProps = nextProps;
9428 return null;
9429 }
9430
9431 reconcileChildren(current, workInProgress, nextChildren);
9432 memoizeProps(workInProgress, nextProps);
9433 return workInProgress.child;
9434 }

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