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

Function updateHostComponent

code/event-handlers/public/app.js:9346–9403  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

9344 }
9345
9346 function updateHostComponent(current, workInProgress, renderExpirationTime) {
9347 pushHostContext(workInProgress);
9348
9349 if (current === null) {
9350 tryToClaimNextHydratableInstance(workInProgress);
9351 }
9352
9353 var type = workInProgress.type;
9354 var memoizedProps = workInProgress.memoizedProps;
9355 var nextProps = workInProgress.pendingProps;
9356 var prevProps = current !== null ? current.memoizedProps : null;
9357
9358 if (hasLegacyContextChanged()) {
9359 // Normally we can bail out on props equality but if context has changed
9360 // we don't do the bailout and we have to reuse existing props instead.
9361 } else if (memoizedProps === nextProps) {
9362 var isHidden = workInProgress.mode & AsyncMode && shouldDeprioritizeSubtree(type, nextProps);
9363 if (isHidden) {
9364 // Before bailing out, make sure we've deprioritized a hidden component.
9365 workInProgress.expirationTime = Never;
9366 }
9367 if (!isHidden || renderExpirationTime !== Never) {
9368 return bailoutOnAlreadyFinishedWork(current, workInProgress);
9369 }
9370 // If we're rendering a hidden node at hidden priority, don't bailout. The
9371 // parent is complete, but the children may not be.
9372 }
9373
9374 var nextChildren = nextProps.children;
9375 var isDirectTextChild = shouldSetTextContent(type, nextProps);
9376
9377 if (isDirectTextChild) {
9378 // We special case a direct text child of a host node. This is a common
9379 // case. We won't handle it as a reified child. We will instead handle
9380 // this in the host environment that also have access to this prop. That
9381 // avoids allocating another HostText fiber and traversing it.
9382 nextChildren = null;
9383 } else if (prevProps && shouldSetTextContent(type, prevProps)) {
9384 // If we're switching from a direct text child to a normal child, or to
9385 // empty, we need to schedule the text content to be reset.
9386 workInProgress.effectTag |= ContentReset;
9387 }
9388
9389 markRef(current, workInProgress);
9390
9391 // Check the host config to see if the children are offscreen/hidden.
9392 if (renderExpirationTime !== Never && workInProgress.mode & AsyncMode && shouldDeprioritizeSubtree(type, nextProps)) {
9393 // Down-prioritize the children.
9394 workInProgress.expirationTime = Never;
9395 // Bailout and come back to this fiber later.
9396 workInProgress.memoizedProps = nextProps;
9397 return null;
9398 }
9399
9400 reconcileChildren(current, workInProgress, nextChildren);
9401 memoizeProps(workInProgress, nextProps);
9402 return workInProgress.child;
9403 }

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