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

Function updateHostComponent

code/styling/public/app.js:10016–10073  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

10014 }
10015
10016 function updateHostComponent(current, workInProgress, renderExpirationTime) {
10017 pushHostContext(workInProgress);
10018
10019 if (current === null) {
10020 tryToClaimNextHydratableInstance(workInProgress);
10021 }
10022
10023 var type = workInProgress.type;
10024 var memoizedProps = workInProgress.memoizedProps;
10025 var nextProps = workInProgress.pendingProps;
10026 var prevProps = current !== null ? current.memoizedProps : null;
10027
10028 if (hasLegacyContextChanged()) {
10029 // Normally we can bail out on props equality but if context has changed
10030 // we don't do the bailout and we have to reuse existing props instead.
10031 } else if (memoizedProps === nextProps) {
10032 var isHidden = workInProgress.mode & AsyncMode && shouldDeprioritizeSubtree(type, nextProps);
10033 if (isHidden) {
10034 // Before bailing out, make sure we've deprioritized a hidden component.
10035 workInProgress.expirationTime = Never;
10036 }
10037 if (!isHidden || renderExpirationTime !== Never) {
10038 return bailoutOnAlreadyFinishedWork(current, workInProgress);
10039 }
10040 // If we're rendering a hidden node at hidden priority, don't bailout. The
10041 // parent is complete, but the children may not be.
10042 }
10043
10044 var nextChildren = nextProps.children;
10045 var isDirectTextChild = shouldSetTextContent(type, nextProps);
10046
10047 if (isDirectTextChild) {
10048 // We special case a direct text child of a host node. This is a common
10049 // case. We won't handle it as a reified child. We will instead handle
10050 // this in the host environment that also have access to this prop. That
10051 // avoids allocating another HostText fiber and traversing it.
10052 nextChildren = null;
10053 } else if (prevProps && shouldSetTextContent(type, prevProps)) {
10054 // If we're switching from a direct text child to a normal child, or to
10055 // empty, we need to schedule the text content to be reset.
10056 workInProgress.effectTag |= ContentReset;
10057 }
10058
10059 markRef(current, workInProgress);
10060
10061 // Check the host config to see if the children are offscreen/hidden.
10062 if (renderExpirationTime !== Never && workInProgress.mode & AsyncMode && shouldDeprioritizeSubtree(type, nextProps)) {
10063 // Down-prioritize the children.
10064 workInProgress.expirationTime = Never;
10065 // Bailout and come back to this fiber later.
10066 workInProgress.memoizedProps = nextProps;
10067 return null;
10068 }
10069
10070 reconcileChildren(current, workInProgress, nextChildren);
10071 memoizeProps(workInProgress, nextProps);
10072 return workInProgress.child;
10073 }

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