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

Function processChildContext

code/dependency-injection/public/app.js:12474–12517  ·  view source on GitHub ↗
(fiber, parentContext)

Source from the content-addressed store, hash-verified

12472 }
12473
12474 function processChildContext(fiber, parentContext) {
12475 var instance = fiber.stateNode;
12476 var childContextTypes = fiber.type.childContextTypes;
12477
12478 // TODO (bvaughn) Replace this behavior with an invariant() in the future.
12479 // It has only been added in Fiber to match the (unintentional) behavior in Stack.
12480 if (typeof instance.getChildContext !== 'function') {
12481 {
12482 var componentName = getComponentName(fiber) || 'Unknown';
12483
12484 if (!warnedAboutMissingGetChildContext[componentName]) {
12485 warnedAboutMissingGetChildContext[componentName] = true;
12486 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);
12487 }
12488 }
12489 return parentContext;
12490 }
12491
12492 var childContext = void 0;
12493 {
12494 ReactDebugCurrentFiber.setCurrentPhase('getChildContext');
12495 }
12496 startPhaseTimer(fiber, 'getChildContext');
12497 childContext = instance.getChildContext();
12498 stopPhaseTimer();
12499 {
12500 ReactDebugCurrentFiber.setCurrentPhase(null);
12501 }
12502 for (var contextKey in childContext) {
12503 !(contextKey in childContextTypes) ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', getComponentName(fiber) || 'Unknown', contextKey) : void 0;
12504 }
12505 {
12506 var name = getComponentName(fiber) || 'Unknown';
12507 checkPropTypes(childContextTypes, childContext, 'child context', name,
12508 // In practice, there is one case in which we won't get a stack. It's when
12509 // somebody calls unstable_renderSubtreeIntoContainer() and we process
12510 // context from the parent component instance. The stack will be missing
12511 // because it's outside of the reconciliation, and so the pointer has not
12512 // been set. This is rare and doesn't matter. We'll also remove that API.
12513 ReactDebugCurrentFiber.getCurrentFiberStackAddendum);
12514 }
12515
12516 return _assign({}, parentContext, childContext);
12517 }
12518
12519 function pushContextProvider(workInProgress) {
12520 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