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

Function processChildContext

code/styling/public/app.js:12381–12424  ·  view source on GitHub ↗
(fiber, parentContext)

Source from the content-addressed store, hash-verified

12379 }
12380
12381 function processChildContext(fiber, parentContext) {
12382 var instance = fiber.stateNode;
12383 var childContextTypes = fiber.type.childContextTypes;
12384
12385 // TODO (bvaughn) Replace this behavior with an invariant() in the future.
12386 // It has only been added in Fiber to match the (unintentional) behavior in Stack.
12387 if (typeof instance.getChildContext !== 'function') {
12388 {
12389 var componentName = getComponentName(fiber) || 'Unknown';
12390
12391 if (!warnedAboutMissingGetChildContext[componentName]) {
12392 warnedAboutMissingGetChildContext[componentName] = true;
12393 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);
12394 }
12395 }
12396 return parentContext;
12397 }
12398
12399 var childContext = void 0;
12400 {
12401 ReactDebugCurrentFiber.setCurrentPhase('getChildContext');
12402 }
12403 startPhaseTimer(fiber, 'getChildContext');
12404 childContext = instance.getChildContext();
12405 stopPhaseTimer();
12406 {
12407 ReactDebugCurrentFiber.setCurrentPhase(null);
12408 }
12409 for (var contextKey in childContext) {
12410 !(contextKey in childContextTypes) ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', getComponentName(fiber) || 'Unknown', contextKey) : void 0;
12411 }
12412 {
12413 var name = getComponentName(fiber) || 'Unknown';
12414 checkPropTypes(childContextTypes, childContext, 'child context', name,
12415 // In practice, there is one case in which we won't get a stack. It's when
12416 // somebody calls unstable_renderSubtreeIntoContainer() and we process
12417 // context from the parent component instance. The stack will be missing
12418 // because it's outside of the reconciliation, and so the pointer has not
12419 // been set. This is rare and doesn't matter. We'll also remove that API.
12420 ReactDebugCurrentFiber.getCurrentFiberStackAddendum);
12421 }
12422
12423 return _assign({}, parentContext, childContext);
12424 }
12425
12426 function pushContextProvider(workInProgress) {
12427 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