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

Function getMaskedContext

code/event-handlers/public/app.js:11644–11676  ·  view source on GitHub ↗
(workInProgress, unmaskedContext)

Source from the content-addressed store, hash-verified

11642 }
11643
11644 function getMaskedContext(workInProgress, unmaskedContext) {
11645 var type = workInProgress.type;
11646 var contextTypes = type.contextTypes;
11647 if (!contextTypes) {
11648 return emptyObject;
11649 }
11650
11651 // Avoid recreating masked context unless unmasked context has changed.
11652 // Failing to do this will result in unnecessary calls to componentWillReceiveProps.
11653 // This may trigger infinite loops if componentWillReceiveProps calls setState.
11654 var instance = workInProgress.stateNode;
11655 if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
11656 return instance.__reactInternalMemoizedMaskedChildContext;
11657 }
11658
11659 var context = {};
11660 for (var key in contextTypes) {
11661 context[key] = unmaskedContext[key];
11662 }
11663
11664 {
11665 var name = getComponentName(workInProgress) || 'Unknown';
11666 checkPropTypes(contextTypes, context, 'context', name, ReactDebugCurrentFiber.getCurrentFiberStackAddendum);
11667 }
11668
11669 // Cache unmasked context so we can avoid recreating masked context unless necessary.
11670 // Context is created before the class component is instantiated so check for instance.
11671 if (instance) {
11672 cacheContext(workInProgress, unmaskedContext, context);
11673 }
11674
11675 return context;
11676 }
11677
11678 function hasContextChanged() {
11679 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