(workInProgress, unmaskedContext)
| 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; |
no test coverage detected