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

Function updateContextConsumer

code/composition/public/app.js:10517–10559  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

10515 }
10516
10517 function updateContextConsumer(current, workInProgress, renderExpirationTime) {
10518 var context = workInProgress.type;
10519 var newProps = workInProgress.pendingProps;
10520 var oldProps = workInProgress.memoizedProps;
10521
10522 var newValue = context._currentValue;
10523 var changedBits = context._changedBits;
10524
10525 if (hasLegacyContextChanged()) {
10526 // Normally we can bail out on props equality but if context has changed
10527 // we don't do the bailout and we have to reuse existing props instead.
10528 } else if (changedBits === 0 && oldProps === newProps) {
10529 return bailoutOnAlreadyFinishedWork(current, workInProgress);
10530 }
10531 workInProgress.memoizedProps = newProps;
10532
10533 var observedBits = newProps.unstable_observedBits;
10534 if (observedBits === undefined || observedBits === null) {
10535 // Subscribe to all changes by default
10536 observedBits = MAX_SIGNED_31_BIT_INT;
10537 }
10538 // Store the observedBits on the fiber's stateNode for quick access.
10539 workInProgress.stateNode = observedBits;
10540
10541 if ((changedBits & observedBits) !== 0) {
10542 // Context change propagation stops at matching consumers, for time-
10543 // slicing. Continue the propagation here.
10544 propagateContextChange(workInProgress, context, changedBits, renderExpirationTime);
10545 } else if (oldProps !== null && oldProps.children === newProps.children) {
10546 // No change. Bailout early if children are the same.
10547 return bailoutOnAlreadyFinishedWork(current, workInProgress);
10548 }
10549
10550 var render = newProps.children;
10551
10552 {
10553 warning(typeof render === 'function', 'A context consumer was rendered with multiple children, or a child ' + "that isn't a function. A context consumer expects a single child " + 'that is a function. If you did pass a function, make sure there ' + 'is no trailing or leading whitespace around it.');
10554 }
10555
10556 var newChildren = render(newValue);
10557 reconcileChildren(current, workInProgress, newChildren);
10558 return workInProgress.child;
10559 }
10560
10561 /*
10562 function reuseChildrenEffects(returnFiber : Fiber, firstChild : Fiber) {

Callers 1

beginWorkFunction · 0.70

Calls 4

warningFunction · 0.85
propagateContextChangeFunction · 0.70
reconcileChildrenFunction · 0.70

Tested by

no test coverage detected