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

Function processChildContext

code/new-context-api/public/app.js:11742–11785  ·  view source on GitHub ↗
(fiber, parentContext)

Source from the content-addressed store, hash-verified

11740 }
11741
11742 function processChildContext(fiber, parentContext) {
11743 var instance = fiber.stateNode;
11744 var childContextTypes = fiber.type.childContextTypes;
11745
11746 // TODO (bvaughn) Replace this behavior with an invariant() in the future.
11747 // It has only been added in Fiber to match the (unintentional) behavior in Stack.
11748 if (typeof instance.getChildContext !== 'function') {
11749 {
11750 var componentName = getComponentName(fiber) || 'Unknown';
11751
11752 if (!warnedAboutMissingGetChildContext[componentName]) {
11753 warnedAboutMissingGetChildContext[componentName] = true;
11754 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);
11755 }
11756 }
11757 return parentContext;
11758 }
11759
11760 var childContext = void 0;
11761 {
11762 ReactDebugCurrentFiber.setCurrentPhase('getChildContext');
11763 }
11764 startPhaseTimer(fiber, 'getChildContext');
11765 childContext = instance.getChildContext();
11766 stopPhaseTimer();
11767 {
11768 ReactDebugCurrentFiber.setCurrentPhase(null);
11769 }
11770 for (var contextKey in childContext) {
11771 !(contextKey in childContextTypes) ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', getComponentName(fiber) || 'Unknown', contextKey) : void 0;
11772 }
11773 {
11774 var name = getComponentName(fiber) || 'Unknown';
11775 checkPropTypes(childContextTypes, childContext, 'child context', name,
11776 // In practice, there is one case in which we won't get a stack. It's when
11777 // somebody calls unstable_renderSubtreeIntoContainer() and we process
11778 // context from the parent component instance. The stack will be missing
11779 // because it's outside of the reconciliation, and so the pointer has not
11780 // been set. This is rare and doesn't matter. We'll also remove that API.
11781 ReactDebugCurrentFiber.getCurrentFiberStackAddendum);
11782 }
11783
11784 return _assign({}, parentContext, childContext);
11785 }
11786
11787 function pushContextProvider(workInProgress) {
11788 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