MCPcopy
hub / github.com/krasimir/react-in-patterns / processChildContext

Function processChildContext

code/composition/public/app.js:12519–12562  ·  view source on GitHub ↗
(fiber, parentContext)

Source from the content-addressed store, hash-verified

12517 }
12518
12519 function processChildContext(fiber, parentContext) {
12520 var instance = fiber.stateNode;
12521 var childContextTypes = fiber.type.childContextTypes;
12522
12523 // TODO (bvaughn) Replace this behavior with an invariant() in the future.
12524 // It has only been added in Fiber to match the (unintentional) behavior in Stack.
12525 if (typeof instance.getChildContext !== 'function') {
12526 {
12527 var componentName = getComponentName(fiber) || 'Unknown';
12528
12529 if (!warnedAboutMissingGetChildContext[componentName]) {
12530 warnedAboutMissingGetChildContext[componentName] = true;
12531 warning(false, '%s.childContextTypes is specified but there is no getChildContext() method ' + 'on the instance. You can either define getChildContext() on %s or remove ' + 'childContextTypes from it.', componentName, componentName);
12532 }
12533 }
12534 return parentContext;
12535 }
12536
12537 var childContext = void 0;
12538 {
12539 ReactDebugCurrentFiber.setCurrentPhase('getChildContext');
12540 }
12541 startPhaseTimer(fiber, 'getChildContext');
12542 childContext = instance.getChildContext();
12543 stopPhaseTimer();
12544 {
12545 ReactDebugCurrentFiber.setCurrentPhase(null);
12546 }
12547 for (var contextKey in childContext) {
12548 !(contextKey in childContextTypes) ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', getComponentName(fiber) || 'Unknown', contextKey) : void 0;
12549 }
12550 {
12551 var name = getComponentName(fiber) || 'Unknown';
12552 checkPropTypes(childContextTypes, childContext, 'child context', name,
12553 // In practice, there is one case in which we won't get a stack. It's when
12554 // somebody calls unstable_renderSubtreeIntoContainer() and we process
12555 // context from the parent component instance. The stack will be missing
12556 // because it's outside of the reconciliation, and so the pointer has not
12557 // been set. This is rare and doesn't matter. We'll also remove that API.
12558 ReactDebugCurrentFiber.getCurrentFiberStackAddendum);
12559 }
12560
12561 return _assign({}, parentContext, childContext);
12562 }
12563
12564 function pushContextProvider(workInProgress) {
12565 if (!isContextProvider(workInProgress)) {

Callers 2

getContextForSubtreeFunction · 0.70

Calls 7

warningFunction · 0.85
getChildContextMethod · 0.80
getComponentNameFunction · 0.70
startPhaseTimerFunction · 0.70
stopPhaseTimerFunction · 0.70
invariantFunction · 0.70
checkPropTypesFunction · 0.70

Tested by

no test coverage detected