(workInProgress, unmaskedContext)
| 11545 | } |
| 11546 | |
| 11547 | function getMaskedContext(workInProgress, unmaskedContext) { |
| 11548 | var type = workInProgress.type; |
| 11549 | var contextTypes = type.contextTypes; |
| 11550 | if (!contextTypes) { |
| 11551 | return emptyObject; |
| 11552 | } |
| 11553 | |
| 11554 | // Avoid recreating masked context unless unmasked context has changed. |
| 11555 | // Failing to do this will result in unnecessary calls to componentWillReceiveProps. |
| 11556 | // This may trigger infinite loops if componentWillReceiveProps calls setState. |
| 11557 | var instance = workInProgress.stateNode; |
| 11558 | if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) { |
| 11559 | return instance.__reactInternalMemoizedMaskedChildContext; |
| 11560 | } |
| 11561 | |
| 11562 | var context = {}; |
| 11563 | for (var key in contextTypes) { |
| 11564 | context[key] = unmaskedContext[key]; |
| 11565 | } |
| 11566 | |
| 11567 | { |
| 11568 | var name = getComponentName(workInProgress) || 'Unknown'; |
| 11569 | checkPropTypes(contextTypes, context, 'context', name, ReactDebugCurrentFiber.getCurrentFiberStackAddendum); |
| 11570 | } |
| 11571 | |
| 11572 | // Cache unmasked context so we can avoid recreating masked context unless necessary. |
| 11573 | // Context is created before the class component is instantiated so check for instance. |
| 11574 | if (instance) { |
| 11575 | cacheContext(workInProgress, unmaskedContext, context); |
| 11576 | } |
| 11577 | |
| 11578 | return context; |
| 11579 | } |
| 11580 | |
| 11581 | function hasContextChanged() { |
| 11582 | return didPerformWorkStackCursor.current; |
no test coverage detected