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

Function updateHostComponent

code/communication/public/app.js:10051–10108  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

10049 }
10050
10051 function updateHostComponent(current, workInProgress, renderExpirationTime) {
10052 pushHostContext(workInProgress);
10053
10054 if (current === null) {
10055 tryToClaimNextHydratableInstance(workInProgress);
10056 }
10057
10058 var type = workInProgress.type;
10059 var memoizedProps = workInProgress.memoizedProps;
10060 var nextProps = workInProgress.pendingProps;
10061 var prevProps = current !== null ? current.memoizedProps : null;
10062
10063 if (hasLegacyContextChanged()) {
10064 // Normally we can bail out on props equality but if context has changed
10065 // we don't do the bailout and we have to reuse existing props instead.
10066 } else if (memoizedProps === nextProps) {
10067 var isHidden = workInProgress.mode & AsyncMode && shouldDeprioritizeSubtree(type, nextProps);
10068 if (isHidden) {
10069 // Before bailing out, make sure we've deprioritized a hidden component.
10070 workInProgress.expirationTime = Never;
10071 }
10072 if (!isHidden || renderExpirationTime !== Never) {
10073 return bailoutOnAlreadyFinishedWork(current, workInProgress);
10074 }
10075 // If we're rendering a hidden node at hidden priority, don't bailout. The
10076 // parent is complete, but the children may not be.
10077 }
10078
10079 var nextChildren = nextProps.children;
10080 var isDirectTextChild = shouldSetTextContent(type, nextProps);
10081
10082 if (isDirectTextChild) {
10083 // We special case a direct text child of a host node. This is a common
10084 // case. We won't handle it as a reified child. We will instead handle
10085 // this in the host environment that also have access to this prop. That
10086 // avoids allocating another HostText fiber and traversing it.
10087 nextChildren = null;
10088 } else if (prevProps && shouldSetTextContent(type, prevProps)) {
10089 // If we're switching from a direct text child to a normal child, or to
10090 // empty, we need to schedule the text content to be reset.
10091 workInProgress.effectTag |= ContentReset;
10092 }
10093
10094 markRef(current, workInProgress);
10095
10096 // Check the host config to see if the children are offscreen/hidden.
10097 if (renderExpirationTime !== Never && workInProgress.mode & AsyncMode && shouldDeprioritizeSubtree(type, nextProps)) {
10098 // Down-prioritize the children.
10099 workInProgress.expirationTime = Never;
10100 // Bailout and come back to this fiber later.
10101 workInProgress.memoizedProps = nextProps;
10102 return null;
10103 }
10104
10105 reconcileChildren(current, workInProgress, nextChildren);
10106 memoizeProps(workInProgress, nextProps);
10107 return workInProgress.child;
10108 }

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