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

Function updateContextConsumer

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

Source from the content-addressed store, hash-verified

10377 }
10378
10379 function updateContextConsumer(current, workInProgress, renderExpirationTime) {
10380 var context = workInProgress.type;
10381 var newProps = workInProgress.pendingProps;
10382 var oldProps = workInProgress.memoizedProps;
10383
10384 var newValue = context._currentValue;
10385 var changedBits = context._changedBits;
10386
10387 if (hasLegacyContextChanged()) {
10388 // Normally we can bail out on props equality but if context has changed
10389 // we don't do the bailout and we have to reuse existing props instead.
10390 } else if (changedBits === 0 && oldProps === newProps) {
10391 return bailoutOnAlreadyFinishedWork(current, workInProgress);
10392 }
10393 workInProgress.memoizedProps = newProps;
10394
10395 var observedBits = newProps.unstable_observedBits;
10396 if (observedBits === undefined || observedBits === null) {
10397 // Subscribe to all changes by default
10398 observedBits = MAX_SIGNED_31_BIT_INT;
10399 }
10400 // Store the observedBits on the fiber's stateNode for quick access.
10401 workInProgress.stateNode = observedBits;
10402
10403 if ((changedBits & observedBits) !== 0) {
10404 // Context change propagation stops at matching consumers, for time-
10405 // slicing. Continue the propagation here.
10406 propagateContextChange(workInProgress, context, changedBits, renderExpirationTime);
10407 } else if (oldProps !== null && oldProps.children === newProps.children) {
10408 // No change. Bailout early if children are the same.
10409 return bailoutOnAlreadyFinishedWork(current, workInProgress);
10410 }
10411
10412 var render = newProps.children;
10413
10414 {
10415 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.');
10416 }
10417
10418 var newChildren = render(newValue);
10419 reconcileChildren(current, workInProgress, newChildren);
10420 return workInProgress.child;
10421 }
10422
10423 /*
10424 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