MCPcopy Create free account
hub / github.com/reactjs/react-rails / getMaskedContext

Function getMaskedContext

lib/assets/react-source/development/react.js:14410–14447  ·  view source on GitHub ↗
(workInProgress, unmaskedContext)

Source from the content-addressed store, hash-verified

14408 }
14409
14410 function getMaskedContext(workInProgress, unmaskedContext) {
14411 {
14412 var type = workInProgress.type;
14413 var contextTypes = type.contextTypes;
14414
14415 if (!contextTypes) {
14416 return emptyContextObject;
14417 } // Avoid recreating masked context unless unmasked context has changed.
14418 // Failing to do this will result in unnecessary calls to componentWillReceiveProps.
14419 // This may trigger infinite loops if componentWillReceiveProps calls setState.
14420
14421
14422 var instance = workInProgress.stateNode;
14423
14424 if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
14425 return instance.__reactInternalMemoizedMaskedChildContext;
14426 }
14427
14428 var context = {};
14429
14430 for (var key in contextTypes) {
14431 context[key] = unmaskedContext[key];
14432 }
14433
14434 {
14435 var name = getComponentName(type) || 'Unknown';
14436 checkPropTypes(contextTypes, context, 'context', name, getCurrentFiberStackInDev);
14437 } // Cache unmasked context so we can avoid recreating masked context unless necessary.
14438 // Context is created before the class component is instantiated so check for instance.
14439
14440
14441 if (instance) {
14442 cacheContext(workInProgress, unmaskedContext, context);
14443 }
14444
14445 return context;
14446 }
14447 }
14448
14449 function hasContextChanged() {
14450 {

Callers 6

constructClassInstanceFunction · 0.85
mountClassInstanceFunction · 0.85
resumeMountClassInstanceFunction · 0.85
updateClassInstanceFunction · 0.85
updateFunctionComponentFunction · 0.85

Calls 3

cacheContextFunction · 0.85
getComponentNameFunction · 0.70
checkPropTypesFunction · 0.70

Tested by

no test coverage detected