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

Function processChildContext

code/redux/public/app.js:12632–12675  ·  view source on GitHub ↗
(fiber, parentContext)

Source from the content-addressed store, hash-verified

12630 }
12631
12632 function processChildContext(fiber, parentContext) {
12633 var instance = fiber.stateNode;
12634 var childContextTypes = fiber.type.childContextTypes;
12635
12636 // TODO (bvaughn) Replace this behavior with an invariant() in the future.
12637 // It has only been added in Fiber to match the (unintentional) behavior in Stack.
12638 if (typeof instance.getChildContext !== 'function') {
12639 {
12640 var componentName = getComponentName(fiber) || 'Unknown';
12641
12642 if (!warnedAboutMissingGetChildContext[componentName]) {
12643 warnedAboutMissingGetChildContext[componentName] = true;
12644 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);
12645 }
12646 }
12647 return parentContext;
12648 }
12649
12650 var childContext = void 0;
12651 {
12652 ReactDebugCurrentFiber.setCurrentPhase('getChildContext');
12653 }
12654 startPhaseTimer(fiber, 'getChildContext');
12655 childContext = instance.getChildContext();
12656 stopPhaseTimer();
12657 {
12658 ReactDebugCurrentFiber.setCurrentPhase(null);
12659 }
12660 for (var contextKey in childContext) {
12661 !(contextKey in childContextTypes) ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', getComponentName(fiber) || 'Unknown', contextKey) : void 0;
12662 }
12663 {
12664 var name = getComponentName(fiber) || 'Unknown';
12665 checkPropTypes(childContextTypes, childContext, 'child context', name,
12666 // In practice, there is one case in which we won't get a stack. It's when
12667 // somebody calls unstable_renderSubtreeIntoContainer() and we process
12668 // context from the parent component instance. The stack will be missing
12669 // because it's outside of the reconciliation, and so the pointer has not
12670 // been set. This is rare and doesn't matter. We'll also remove that API.
12671 ReactDebugCurrentFiber.getCurrentFiberStackAddendum);
12672 }
12673
12674 return _assign({}, parentContext, childContext);
12675 }
12676
12677 function pushContextProvider(workInProgress) {
12678 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