MCPcopy Index your code
hub / github.com/krasimir/react-in-patterns / getMaskedContext

Function getMaskedContext

code/composition/public/app.js:12452–12484  ·  view source on GitHub ↗
(workInProgress, unmaskedContext)

Source from the content-addressed store, hash-verified

12450 }
12451
12452 function getMaskedContext(workInProgress, unmaskedContext) {
12453 var type = workInProgress.type;
12454 var contextTypes = type.contextTypes;
12455 if (!contextTypes) {
12456 return emptyObject;
12457 }
12458
12459 // Avoid recreating masked context unless unmasked context has changed.
12460 // Failing to do this will result in unnecessary calls to componentWillReceiveProps.
12461 // This may trigger infinite loops if componentWillReceiveProps calls setState.
12462 var instance = workInProgress.stateNode;
12463 if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
12464 return instance.__reactInternalMemoizedMaskedChildContext;
12465 }
12466
12467 var context = {};
12468 for (var key in contextTypes) {
12469 context[key] = unmaskedContext[key];
12470 }
12471
12472 {
12473 var name = getComponentName(workInProgress) || 'Unknown';
12474 checkPropTypes(contextTypes, context, 'context', name, ReactDebugCurrentFiber.getCurrentFiberStackAddendum);
12475 }
12476
12477 // Cache unmasked context so we can avoid recreating masked context unless necessary.
12478 // Context is created before the class component is instantiated so check for instance.
12479 if (instance) {
12480 cacheContext(workInProgress, unmaskedContext, context);
12481 }
12482
12483 return context;
12484 }
12485
12486 function hasContextChanged() {
12487 return didPerformWorkStackCursor.current;

Callers 6

constructClassInstanceFunction · 0.70
mountClassInstanceFunction · 0.70
resumeMountClassInstanceFunction · 0.70
updateClassInstanceFunction · 0.70

Calls 3

getComponentNameFunction · 0.70
checkPropTypesFunction · 0.70
cacheContextFunction · 0.70

Tested by

no test coverage detected