(workInProgress, unmaskedContext)
| 12405 | } |
| 12406 | |
| 12407 | function getMaskedContext(workInProgress, unmaskedContext) { |
| 12408 | var type = workInProgress.type; |
| 12409 | var contextTypes = type.contextTypes; |
| 12410 | if (!contextTypes) { |
| 12411 | return emptyObject; |
| 12412 | } |
| 12413 | |
| 12414 | // Avoid recreating masked context unless unmasked context has changed. |
| 12415 | // Failing to do this will result in unnecessary calls to componentWillReceiveProps. |
| 12416 | // This may trigger infinite loops if componentWillReceiveProps calls setState. |
| 12417 | var instance = workInProgress.stateNode; |
| 12418 | if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) { |
| 12419 | return instance.__reactInternalMemoizedMaskedChildContext; |
| 12420 | } |
| 12421 | |
| 12422 | var context = {}; |
| 12423 | for (var key in contextTypes) { |
| 12424 | context[key] = unmaskedContext[key]; |
| 12425 | } |
| 12426 | |
| 12427 | { |
| 12428 | var name = getComponentName(workInProgress) || 'Unknown'; |
| 12429 | checkPropTypes(contextTypes, context, 'context', name, ReactDebugCurrentFiber.getCurrentFiberStackAddendum); |
| 12430 | } |
| 12431 | |
| 12432 | // Cache unmasked context so we can avoid recreating masked context unless necessary. |
| 12433 | // Context is created before the class component is instantiated so check for instance. |
| 12434 | if (instance) { |
| 12435 | cacheContext(workInProgress, unmaskedContext, context); |
| 12436 | } |
| 12437 | |
| 12438 | return context; |
| 12439 | } |
| 12440 | |
| 12441 | function hasContextChanged() { |
| 12442 | return didPerformWorkStackCursor.current; |
no test coverage detected