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

Function updateHostComponent

code/dependency-injection/public/app.js:10109–10166  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

10107 }
10108
10109 function updateHostComponent(current, workInProgress, renderExpirationTime) {
10110 pushHostContext(workInProgress);
10111
10112 if (current === null) {
10113 tryToClaimNextHydratableInstance(workInProgress);
10114 }
10115
10116 var type = workInProgress.type;
10117 var memoizedProps = workInProgress.memoizedProps;
10118 var nextProps = workInProgress.pendingProps;
10119 var prevProps = current !== null ? current.memoizedProps : null;
10120
10121 if (hasLegacyContextChanged()) {
10122 // Normally we can bail out on props equality but if context has changed
10123 // we don't do the bailout and we have to reuse existing props instead.
10124 } else if (memoizedProps === nextProps) {
10125 var isHidden = workInProgress.mode & AsyncMode && shouldDeprioritizeSubtree(type, nextProps);
10126 if (isHidden) {
10127 // Before bailing out, make sure we've deprioritized a hidden component.
10128 workInProgress.expirationTime = Never;
10129 }
10130 if (!isHidden || renderExpirationTime !== Never) {
10131 return bailoutOnAlreadyFinishedWork(current, workInProgress);
10132 }
10133 // If we're rendering a hidden node at hidden priority, don't bailout. The
10134 // parent is complete, but the children may not be.
10135 }
10136
10137 var nextChildren = nextProps.children;
10138 var isDirectTextChild = shouldSetTextContent(type, nextProps);
10139
10140 if (isDirectTextChild) {
10141 // We special case a direct text child of a host node. This is a common
10142 // case. We won't handle it as a reified child. We will instead handle
10143 // this in the host environment that also have access to this prop. That
10144 // avoids allocating another HostText fiber and traversing it.
10145 nextChildren = null;
10146 } else if (prevProps && shouldSetTextContent(type, prevProps)) {
10147 // If we're switching from a direct text child to a normal child, or to
10148 // empty, we need to schedule the text content to be reset.
10149 workInProgress.effectTag |= ContentReset;
10150 }
10151
10152 markRef(current, workInProgress);
10153
10154 // Check the host config to see if the children are offscreen/hidden.
10155 if (renderExpirationTime !== Never && workInProgress.mode & AsyncMode && shouldDeprioritizeSubtree(type, nextProps)) {
10156 // Down-prioritize the children.
10157 workInProgress.expirationTime = Never;
10158 // Bailout and come back to this fiber later.
10159 workInProgress.memoizedProps = nextProps;
10160 return null;
10161 }
10162
10163 reconcileChildren(current, workInProgress, nextChildren);
10164 memoizeProps(workInProgress, nextProps);
10165 return workInProgress.child;
10166 }

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