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

Function updateHostComponent

code/redux/public/app.js:10267–10324  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

10265 }
10266
10267 function updateHostComponent(current, workInProgress, renderExpirationTime) {
10268 pushHostContext(workInProgress);
10269
10270 if (current === null) {
10271 tryToClaimNextHydratableInstance(workInProgress);
10272 }
10273
10274 var type = workInProgress.type;
10275 var memoizedProps = workInProgress.memoizedProps;
10276 var nextProps = workInProgress.pendingProps;
10277 var prevProps = current !== null ? current.memoizedProps : null;
10278
10279 if (hasLegacyContextChanged()) {
10280 // Normally we can bail out on props equality but if context has changed
10281 // we don't do the bailout and we have to reuse existing props instead.
10282 } else if (memoizedProps === nextProps) {
10283 var isHidden = workInProgress.mode & AsyncMode && shouldDeprioritizeSubtree(type, nextProps);
10284 if (isHidden) {
10285 // Before bailing out, make sure we've deprioritized a hidden component.
10286 workInProgress.expirationTime = Never;
10287 }
10288 if (!isHidden || renderExpirationTime !== Never) {
10289 return bailoutOnAlreadyFinishedWork(current, workInProgress);
10290 }
10291 // If we're rendering a hidden node at hidden priority, don't bailout. The
10292 // parent is complete, but the children may not be.
10293 }
10294
10295 var nextChildren = nextProps.children;
10296 var isDirectTextChild = shouldSetTextContent(type, nextProps);
10297
10298 if (isDirectTextChild) {
10299 // We special case a direct text child of a host node. This is a common
10300 // case. We won't handle it as a reified child. We will instead handle
10301 // this in the host environment that also have access to this prop. That
10302 // avoids allocating another HostText fiber and traversing it.
10303 nextChildren = null;
10304 } else if (prevProps && shouldSetTextContent(type, prevProps)) {
10305 // If we're switching from a direct text child to a normal child, or to
10306 // empty, we need to schedule the text content to be reset.
10307 workInProgress.effectTag |= ContentReset;
10308 }
10309
10310 markRef(current, workInProgress);
10311
10312 // Check the host config to see if the children are offscreen/hidden.
10313 if (renderExpirationTime !== Never && workInProgress.mode & AsyncMode && shouldDeprioritizeSubtree(type, nextProps)) {
10314 // Down-prioritize the children.
10315 workInProgress.expirationTime = Never;
10316 // Bailout and come back to this fiber later.
10317 workInProgress.memoizedProps = nextProps;
10318 return null;
10319 }
10320
10321 reconcileChildren(current, workInProgress, nextChildren);
10322 memoizeProps(workInProgress, nextProps);
10323 return workInProgress.child;
10324 }

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