(workInProgress, unmaskedContext)
| 12306 | } |
| 12307 | |
| 12308 | function getMaskedContext(workInProgress, unmaskedContext) { |
| 12309 | var type = workInProgress.type; |
| 12310 | var contextTypes = type.contextTypes; |
| 12311 | if (!contextTypes) { |
| 12312 | return emptyObject; |
| 12313 | } |
| 12314 | |
| 12315 | // Avoid recreating masked context unless unmasked context has changed. |
| 12316 | // Failing to do this will result in unnecessary calls to componentWillReceiveProps. |
| 12317 | // This may trigger infinite loops if componentWillReceiveProps calls setState. |
| 12318 | var instance = workInProgress.stateNode; |
| 12319 | if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) { |
| 12320 | return instance.__reactInternalMemoizedMaskedChildContext; |
| 12321 | } |
| 12322 | |
| 12323 | var context = {}; |
| 12324 | for (var key in contextTypes) { |
| 12325 | context[key] = unmaskedContext[key]; |
| 12326 | } |
| 12327 | |
| 12328 | { |
| 12329 | var name = getComponentName(workInProgress) || 'Unknown'; |
| 12330 | checkPropTypes(contextTypes, context, 'context', name, ReactDebugCurrentFiber.getCurrentFiberStackAddendum); |
| 12331 | } |
| 12332 | |
| 12333 | // Cache unmasked context so we can avoid recreating masked context unless necessary. |
| 12334 | // Context is created before the class component is instantiated so check for instance. |
| 12335 | if (instance) { |
| 12336 | cacheContext(workInProgress, unmaskedContext, context); |
| 12337 | } |
| 12338 | |
| 12339 | return context; |
| 12340 | } |
| 12341 | |
| 12342 | function hasContextChanged() { |
| 12343 | return didPerformWorkStackCursor.current; |
no test coverage detected