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

Function getMaskedContext

code/communication/public/app.js:12349–12381  ·  view source on GitHub ↗
(workInProgress, unmaskedContext)

Source from the content-addressed store, hash-verified

12347 }
12348
12349 function getMaskedContext(workInProgress, unmaskedContext) {
12350 var type = workInProgress.type;
12351 var contextTypes = type.contextTypes;
12352 if (!contextTypes) {
12353 return emptyObject;
12354 }
12355
12356 // Avoid recreating masked context unless unmasked context has changed.
12357 // Failing to do this will result in unnecessary calls to componentWillReceiveProps.
12358 // This may trigger infinite loops if componentWillReceiveProps calls setState.
12359 var instance = workInProgress.stateNode;
12360 if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
12361 return instance.__reactInternalMemoizedMaskedChildContext;
12362 }
12363
12364 var context = {};
12365 for (var key in contextTypes) {
12366 context[key] = unmaskedContext[key];
12367 }
12368
12369 {
12370 var name = getComponentName(workInProgress) || 'Unknown';
12371 checkPropTypes(contextTypes, context, 'context', name, ReactDebugCurrentFiber.getCurrentFiberStackAddendum);
12372 }
12373
12374 // Cache unmasked context so we can avoid recreating masked context unless necessary.
12375 // Context is created before the class component is instantiated so check for instance.
12376 if (instance) {
12377 cacheContext(workInProgress, unmaskedContext, context);
12378 }
12379
12380 return context;
12381 }
12382
12383 function hasContextChanged() {
12384 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