MCPcopy Index your code
hub / github.com/microsoft/SandDance / updateContextConsumer

Function updateContextConsumer

docs/external/js/react-dom.development.js:18397–18447  ·  view source on GitHub ↗
(current, workInProgress, renderExpirationTime)

Source from the content-addressed store, hash-verified

18395 var hasWarnedAboutUsingContextAsConsumer = false;
18396
18397 function updateContextConsumer(current, workInProgress, renderExpirationTime) {
18398 var context = workInProgress.type; // The logic below for Context differs depending on PROD or DEV mode. In
18399 // DEV mode, we create a separate object for Context.Consumer that acts
18400 // like a proxy to Context. This proxy object adds unnecessary code in PROD
18401 // so we use the old behaviour (Context.Consumer references Context) to
18402 // reduce size and overhead. The separate object references context via
18403 // a property called "_context", which also gives us the ability to check
18404 // in DEV mode if this property exists or not and warn if it does not.
18405
18406 {
18407 if (context._context === undefined) {
18408 // This may be because it's a Context (rather than a Consumer).
18409 // Or it may be because it's older React where they're the same thing.
18410 // We only want to warn if we're sure it's a new React.
18411 if (context !== context.Consumer) {
18412 if (!hasWarnedAboutUsingContextAsConsumer) {
18413 hasWarnedAboutUsingContextAsConsumer = true;
18414
18415 error('Rendering <Context> directly is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
18416 }
18417 }
18418 } else {
18419 context = context._context;
18420 }
18421 }
18422
18423 var newProps = workInProgress.pendingProps;
18424 var render = newProps.children;
18425
18426 {
18427 if (typeof render !== 'function') {
18428 error('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.');
18429 }
18430 }
18431
18432 prepareToReadContext(workInProgress, renderExpirationTime);
18433 var newValue = readContext(context, newProps.unstable_observedBits);
18434 var newChildren;
18435
18436 {
18437 ReactCurrentOwner$1.current = workInProgress;
18438 setIsRendering(true);
18439 newChildren = render(newValue);
18440 setIsRendering(false);
18441 } // React DevTools reads this flag.
18442
18443
18444 workInProgress.effectTag |= PerformedWork;
18445 reconcileChildren(current, workInProgress, newChildren, renderExpirationTime);
18446 return workInProgress.child;
18447 }
18448
18449 function markWorkInProgressReceivedUpdate() {
18450 didReceiveUpdate = true;

Callers 1

beginWorkFunction · 0.85

Calls 6

prepareToReadContextFunction · 0.85
readContextFunction · 0.85
setIsRenderingFunction · 0.85
reconcileChildrenFunction · 0.85
errorFunction · 0.70
renderFunction · 0.70

Tested by

no test coverage detected