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

Function processChildContext

code/third-party/public/app.js:11614–11657  ·  view source on GitHub ↗
(fiber, parentContext)

Source from the content-addressed store, hash-verified

11612 }
11613
11614 function processChildContext(fiber, parentContext) {
11615 var instance = fiber.stateNode;
11616 var childContextTypes = fiber.type.childContextTypes;
11617
11618 // TODO (bvaughn) Replace this behavior with an invariant() in the future.
11619 // It has only been added in Fiber to match the (unintentional) behavior in Stack.
11620 if (typeof instance.getChildContext !== 'function') {
11621 {
11622 var componentName = getComponentName(fiber) || 'Unknown';
11623
11624 if (!warnedAboutMissingGetChildContext[componentName]) {
11625 warnedAboutMissingGetChildContext[componentName] = true;
11626 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);
11627 }
11628 }
11629 return parentContext;
11630 }
11631
11632 var childContext = void 0;
11633 {
11634 ReactDebugCurrentFiber.setCurrentPhase('getChildContext');
11635 }
11636 startPhaseTimer(fiber, 'getChildContext');
11637 childContext = instance.getChildContext();
11638 stopPhaseTimer();
11639 {
11640 ReactDebugCurrentFiber.setCurrentPhase(null);
11641 }
11642 for (var contextKey in childContext) {
11643 !(contextKey in childContextTypes) ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', getComponentName(fiber) || 'Unknown', contextKey) : void 0;
11644 }
11645 {
11646 var name = getComponentName(fiber) || 'Unknown';
11647 checkPropTypes(childContextTypes, childContext, 'child context', name,
11648 // In practice, there is one case in which we won't get a stack. It's when
11649 // somebody calls unstable_renderSubtreeIntoContainer() and we process
11650 // context from the parent component instance. The stack will be missing
11651 // because it's outside of the reconciliation, and so the pointer has not
11652 // been set. This is rare and doesn't matter. We'll also remove that API.
11653 ReactDebugCurrentFiber.getCurrentFiberStackAddendum);
11654 }
11655
11656 return _assign({}, parentContext, childContext);
11657 }
11658
11659 function pushContextProvider(workInProgress) {
11660 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