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

Function getMaskedContext

code/redux/public/app.js:12565–12597  ·  view source on GitHub ↗
(workInProgress, unmaskedContext)

Source from the content-addressed store, hash-verified

12563 }
12564
12565 function getMaskedContext(workInProgress, unmaskedContext) {
12566 var type = workInProgress.type;
12567 var contextTypes = type.contextTypes;
12568 if (!contextTypes) {
12569 return emptyObject;
12570 }
12571
12572 // Avoid recreating masked context unless unmasked context has changed.
12573 // Failing to do this will result in unnecessary calls to componentWillReceiveProps.
12574 // This may trigger infinite loops if componentWillReceiveProps calls setState.
12575 var instance = workInProgress.stateNode;
12576 if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
12577 return instance.__reactInternalMemoizedMaskedChildContext;
12578 }
12579
12580 var context = {};
12581 for (var key in contextTypes) {
12582 context[key] = unmaskedContext[key];
12583 }
12584
12585 {
12586 var name = getComponentName(workInProgress) || 'Unknown';
12587 checkPropTypes(contextTypes, context, 'context', name, ReactDebugCurrentFiber.getCurrentFiberStackAddendum);
12588 }
12589
12590 // Cache unmasked context so we can avoid recreating masked context unless necessary.
12591 // Context is created before the class component is instantiated so check for instance.
12592 if (instance) {
12593 cacheContext(workInProgress, unmaskedContext, context);
12594 }
12595
12596 return context;
12597 }
12598
12599 function hasContextChanged() {
12600 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