MCPcopy
hub / github.com/tastejs/todomvc / processChildContext

Function processChildContext

examples/typescript-react/js/bundle.js:10396–10439  ·  view source on GitHub ↗
(fiber, type, parentContext)

Source from the content-addressed store, hash-verified

10394}
10395
10396function processChildContext(fiber, type, parentContext) {
10397 var instance = fiber.stateNode;
10398 var childContextTypes = type.childContextTypes;
10399
10400 // TODO (bvaughn) Replace this behavior with an invariant() in the future.
10401 // It has only been added in Fiber to match the (unintentional) behavior in Stack.
10402 if (typeof instance.getChildContext !== 'function') {
10403 {
10404 var componentName = getComponentName(type) || 'Unknown';
10405
10406 if (!warnedAboutMissingGetChildContext[componentName]) {
10407 warnedAboutMissingGetChildContext[componentName] = true;
10408 warningWithoutStack$1(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);
10409 }
10410 }
10411 return parentContext;
10412 }
10413
10414 var childContext = void 0;
10415 {
10416 setCurrentPhase('getChildContext');
10417 }
10418 startPhaseTimer(fiber, 'getChildContext');
10419 childContext = instance.getChildContext();
10420 stopPhaseTimer();
10421 {
10422 setCurrentPhase(null);
10423 }
10424 for (var contextKey in childContext) {
10425 !(contextKey in childContextTypes) ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', getComponentName(type) || 'Unknown', contextKey) : void 0;
10426 }
10427 {
10428 var name = getComponentName(type) || 'Unknown';
10429 checkPropTypes(childContextTypes, childContext, 'child context', name,
10430 // In practice, there is one case in which we won't get a stack. It's when
10431 // somebody calls unstable_renderSubtreeIntoContainer() and we process
10432 // context from the parent component instance. The stack will be missing
10433 // because it's outside of the reconciliation, and so the pointer has not
10434 // been set. This is rare and doesn't matter. We'll also remove that API.
10435 getCurrentFiberStackInDev);
10436 }
10437
10438 return _assign({}, parentContext, childContext);
10439}
10440
10441function pushContextProvider(workInProgress) {
10442 var instance = workInProgress.stateNode;

Callers 2

getContextForSubtreeFunction · 0.85

Calls 6

getComponentNameFunction · 0.85
setCurrentPhaseFunction · 0.85
startPhaseTimerFunction · 0.85
stopPhaseTimerFunction · 0.85
invariantFunction · 0.70
checkPropTypesFunction · 0.70

Tested by

no test coverage detected