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

Function getMaskedContext

code/new-context-api/public/app.js:11675–11707  ·  view source on GitHub ↗
(workInProgress, unmaskedContext)

Source from the content-addressed store, hash-verified

11673 }
11674
11675 function getMaskedContext(workInProgress, unmaskedContext) {
11676 var type = workInProgress.type;
11677 var contextTypes = type.contextTypes;
11678 if (!contextTypes) {
11679 return emptyObject;
11680 }
11681
11682 // Avoid recreating masked context unless unmasked context has changed.
11683 // Failing to do this will result in unnecessary calls to componentWillReceiveProps.
11684 // This may trigger infinite loops if componentWillReceiveProps calls setState.
11685 var instance = workInProgress.stateNode;
11686 if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
11687 return instance.__reactInternalMemoizedMaskedChildContext;
11688 }
11689
11690 var context = {};
11691 for (var key in contextTypes) {
11692 context[key] = unmaskedContext[key];
11693 }
11694
11695 {
11696 var name = getComponentName(workInProgress) || 'Unknown';
11697 checkPropTypes(contextTypes, context, 'context', name, ReactDebugCurrentFiber.getCurrentFiberStackAddendum);
11698 }
11699
11700 // Cache unmasked context so we can avoid recreating masked context unless necessary.
11701 // Context is created before the class component is instantiated so check for instance.
11702 if (instance) {
11703 cacheContext(workInProgress, unmaskedContext, context);
11704 }
11705
11706 return context;
11707 }
11708
11709 function hasContextChanged() {
11710 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