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

Function getMaskedContext

code/higher-order-components/public/app.js:12308–12340  ·  view source on GitHub ↗
(workInProgress, unmaskedContext)

Source from the content-addressed store, hash-verified

12306 }
12307
12308 function getMaskedContext(workInProgress, unmaskedContext) {
12309 var type = workInProgress.type;
12310 var contextTypes = type.contextTypes;
12311 if (!contextTypes) {
12312 return emptyObject;
12313 }
12314
12315 // Avoid recreating masked context unless unmasked context has changed.
12316 // Failing to do this will result in unnecessary calls to componentWillReceiveProps.
12317 // This may trigger infinite loops if componentWillReceiveProps calls setState.
12318 var instance = workInProgress.stateNode;
12319 if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
12320 return instance.__reactInternalMemoizedMaskedChildContext;
12321 }
12322
12323 var context = {};
12324 for (var key in contextTypes) {
12325 context[key] = unmaskedContext[key];
12326 }
12327
12328 {
12329 var name = getComponentName(workInProgress) || 'Unknown';
12330 checkPropTypes(contextTypes, context, 'context', name, ReactDebugCurrentFiber.getCurrentFiberStackAddendum);
12331 }
12332
12333 // Cache unmasked context so we can avoid recreating masked context unless necessary.
12334 // Context is created before the class component is instantiated so check for instance.
12335 if (instance) {
12336 cacheContext(workInProgress, unmaskedContext, context);
12337 }
12338
12339 return context;
12340 }
12341
12342 function hasContextChanged() {
12343 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