(workInProgress, unmaskedContext)
| 11636 | } |
| 11637 | |
| 11638 | function getMaskedContext(workInProgress, unmaskedContext) { |
| 11639 | var type = workInProgress.type; |
| 11640 | var contextTypes = type.contextTypes; |
| 11641 | if (!contextTypes) { |
| 11642 | return emptyObject; |
| 11643 | } |
| 11644 | |
| 11645 | // Avoid recreating masked context unless unmasked context has changed. |
| 11646 | // Failing to do this will result in unnecessary calls to componentWillReceiveProps. |
| 11647 | // This may trigger infinite loops if componentWillReceiveProps calls setState. |
| 11648 | var instance = workInProgress.stateNode; |
| 11649 | if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) { |
| 11650 | return instance.__reactInternalMemoizedMaskedChildContext; |
| 11651 | } |
| 11652 | |
| 11653 | var context = {}; |
| 11654 | for (var key in contextTypes) { |
| 11655 | context[key] = unmaskedContext[key]; |
| 11656 | } |
| 11657 | |
| 11658 | { |
| 11659 | var name = getComponentName(workInProgress) || 'Unknown'; |
| 11660 | checkPropTypes(contextTypes, context, 'context', name, ReactDebugCurrentFiber.getCurrentFiberStackAddendum); |
| 11661 | } |
| 11662 | |
| 11663 | // Cache unmasked context so we can avoid recreating masked context unless necessary. |
| 11664 | // Context is created before the class component is instantiated so check for instance. |
| 11665 | if (instance) { |
| 11666 | cacheContext(workInProgress, unmaskedContext, context); |
| 11667 | } |
| 11668 | |
| 11669 | return context; |
| 11670 | } |
| 11671 | |
| 11672 | function hasContextChanged() { |
| 11673 | return didPerformWorkStackCursor.current; |
no test coverage detected