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