MCPcopy Index your code
hub / github.com/microsoft/SandDance / processChildContext

Function processChildContext

docs/external/js/react-dom.development.js:10917–10962  ·  view source on GitHub ↗
(fiber, type, parentContext)

Source from the content-addressed store, hash-verified

10915 }
10916
10917 function processChildContext(fiber, type, parentContext) {
10918 {
10919 var instance = fiber.stateNode;
10920 var childContextTypes = type.childContextTypes; // TODO (bvaughn) Replace this behavior with an invariant() in the future.
10921 // It has only been added in Fiber to match the (unintentional) behavior in Stack.
10922
10923 if (typeof instance.getChildContext !== 'function') {
10924 {
10925 var componentName = getComponentName(type) || 'Unknown';
10926
10927 if (!warnedAboutMissingGetChildContext[componentName]) {
10928 warnedAboutMissingGetChildContext[componentName] = true;
10929
10930 error('%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);
10931 }
10932 }
10933
10934 return parentContext;
10935 }
10936
10937 var childContext;
10938 startPhaseTimer(fiber, 'getChildContext');
10939 childContext = instance.getChildContext();
10940 stopPhaseTimer();
10941
10942 for (var contextKey in childContext) {
10943 if (!(contextKey in childContextTypes)) {
10944 {
10945 throw Error( (getComponentName(type) || 'Unknown') + ".getChildContext(): key \"" + contextKey + "\" is not defined in childContextTypes." );
10946 }
10947 }
10948 }
10949
10950 {
10951 var name = getComponentName(type) || 'Unknown';
10952 checkPropTypes_1(childContextTypes, childContext, 'child context', name, // In practice, there is one case in which we won't get a stack. It's when
10953 // somebody calls unstable_renderSubtreeIntoContainer() and we process
10954 // context from the parent component instance. The stack will be missing
10955 // because it's outside of the reconciliation, and so the pointer has not
10956 // been set. This is rare and doesn't matter. We'll also remove that API.
10957 getCurrentFiberStackInDev);
10958 }
10959
10960 return _assign({}, parentContext, {}, childContext);
10961 }
10962 }
10963
10964 function pushContextProvider(workInProgress) {
10965 {

Callers 2

getContextForSubtreeFunction · 0.85

Calls 4

startPhaseTimerFunction · 0.85
stopPhaseTimerFunction · 0.85
getComponentNameFunction · 0.70
errorFunction · 0.70

Tested by

no test coverage detected