(workInProgress, unmaskedContext)
| 12450 | } |
| 12451 | |
| 12452 | function getMaskedContext(workInProgress, unmaskedContext) { |
| 12453 | var type = workInProgress.type; |
| 12454 | var contextTypes = type.contextTypes; |
| 12455 | if (!contextTypes) { |
| 12456 | return emptyObject; |
| 12457 | } |
| 12458 | |
| 12459 | // Avoid recreating masked context unless unmasked context has changed. |
| 12460 | // Failing to do this will result in unnecessary calls to componentWillReceiveProps. |
| 12461 | // This may trigger infinite loops if componentWillReceiveProps calls setState. |
| 12462 | var instance = workInProgress.stateNode; |
| 12463 | if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) { |
| 12464 | return instance.__reactInternalMemoizedMaskedChildContext; |
| 12465 | } |
| 12466 | |
| 12467 | var context = {}; |
| 12468 | for (var key in contextTypes) { |
| 12469 | context[key] = unmaskedContext[key]; |
| 12470 | } |
| 12471 | |
| 12472 | { |
| 12473 | var name = getComponentName(workInProgress) || 'Unknown'; |
| 12474 | checkPropTypes(contextTypes, context, 'context', name, ReactDebugCurrentFiber.getCurrentFiberStackAddendum); |
| 12475 | } |
| 12476 | |
| 12477 | // Cache unmasked context so we can avoid recreating masked context unless necessary. |
| 12478 | // Context is created before the class component is instantiated so check for instance. |
| 12479 | if (instance) { |
| 12480 | cacheContext(workInProgress, unmaskedContext, context); |
| 12481 | } |
| 12482 | |
| 12483 | return context; |
| 12484 | } |
| 12485 | |
| 12486 | function hasContextChanged() { |
| 12487 | return didPerformWorkStackCursor.current; |
no test coverage detected