MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / getMaskedContext

Function getMaskedContext

code/third-party/public/app.js:11547–11579  ·  view source on GitHub ↗
(workInProgress, unmaskedContext)

Source from the content-addressed store, hash-verified

11545 }
11546
11547 function getMaskedContext(workInProgress, unmaskedContext) {
11548 var type = workInProgress.type;
11549 var contextTypes = type.contextTypes;
11550 if (!contextTypes) {
11551 return emptyObject;
11552 }
11553
11554 // Avoid recreating masked context unless unmasked context has changed.
11555 // Failing to do this will result in unnecessary calls to componentWillReceiveProps.
11556 // This may trigger infinite loops if componentWillReceiveProps calls setState.
11557 var instance = workInProgress.stateNode;
11558 if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
11559 return instance.__reactInternalMemoizedMaskedChildContext;
11560 }
11561
11562 var context = {};
11563 for (var key in contextTypes) {
11564 context[key] = unmaskedContext[key];
11565 }
11566
11567 {
11568 var name = getComponentName(workInProgress) || 'Unknown';
11569 checkPropTypes(contextTypes, context, 'context', name, ReactDebugCurrentFiber.getCurrentFiberStackAddendum);
11570 }
11571
11572 // Cache unmasked context so we can avoid recreating masked context unless necessary.
11573 // Context is created before the class component is instantiated so check for instance.
11574 if (instance) {
11575 cacheContext(workInProgress, unmaskedContext, context);
11576 }
11577
11578 return context;
11579 }
11580
11581 function hasContextChanged() {
11582 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