(workInProgress, unmaskedContext)
| 11809 | } |
| 11810 | |
| 11811 | function getMaskedContext(workInProgress, unmaskedContext) { |
| 11812 | { |
| 11813 | var type = workInProgress.type; |
| 11814 | var contextTypes = type.contextTypes; |
| 11815 | |
| 11816 | if (!contextTypes) { |
| 11817 | return emptyContextObject; |
| 11818 | } // Avoid recreating masked context unless unmasked context has changed. |
| 11819 | // Failing to do this will result in unnecessary calls to componentWillReceiveProps. |
| 11820 | // This may trigger infinite loops if componentWillReceiveProps calls setState. |
| 11821 | |
| 11822 | |
| 11823 | var instance = workInProgress.stateNode; |
| 11824 | |
| 11825 | if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) { |
| 11826 | return instance.__reactInternalMemoizedMaskedChildContext; |
| 11827 | } |
| 11828 | |
| 11829 | var context = {}; |
| 11830 | |
| 11831 | for (var key in contextTypes) { |
| 11832 | context[key] = unmaskedContext[key]; |
| 11833 | } |
| 11834 | |
| 11835 | { |
| 11836 | var name = getComponentNameFromFiber(workInProgress) || 'Unknown'; |
| 11837 | checkPropTypes(contextTypes, context, 'context', name); |
| 11838 | } // Cache unmasked context so we can avoid recreating masked context unless necessary. |
| 11839 | // Context is created before the class component is instantiated so check for instance. |
| 11840 | |
| 11841 | |
| 11842 | if (instance) { |
| 11843 | cacheContext(workInProgress, unmaskedContext, context); |
| 11844 | } |
| 11845 | |
| 11846 | return context; |
| 11847 | } |
| 11848 | } |
| 11849 | |
| 11850 | function hasContextChanged() { |
| 11851 | { |
no test coverage detected
searching dependent graphs…