(current, workInProgress, ctor, newProps, renderLanes)
| 18520 | |
| 18521 | |
| 18522 | function updateClassInstance(current, workInProgress, ctor, newProps, renderLanes) { |
| 18523 | var instance = workInProgress.stateNode; |
| 18524 | cloneUpdateQueue(current, workInProgress); |
| 18525 | var unresolvedOldProps = workInProgress.memoizedProps; |
| 18526 | var oldProps = workInProgress.type === workInProgress.elementType ? unresolvedOldProps : resolveDefaultProps(workInProgress.type, unresolvedOldProps); |
| 18527 | instance.props = oldProps; |
| 18528 | var unresolvedNewProps = workInProgress.pendingProps; |
| 18529 | var oldContext = instance.context; |
| 18530 | var contextType = ctor.contextType; |
| 18531 | var nextContext = emptyContextObject; |
| 18532 | |
| 18533 | if (typeof contextType === 'object' && contextType !== null) { |
| 18534 | nextContext = readContext(contextType); |
| 18535 | } else { |
| 18536 | var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true); |
| 18537 | nextContext = getMaskedContext(workInProgress, nextUnmaskedContext); |
| 18538 | } |
| 18539 | |
| 18540 | var getDerivedStateFromProps = ctor.getDerivedStateFromProps; |
| 18541 | var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what |
| 18542 | // ever the previously attempted to render - not the "current". However, |
| 18543 | // during componentDidUpdate we pass the "current" props. |
| 18544 | // In order to support react-lifecycles-compat polyfilled components, |
| 18545 | // Unsafe lifecycles should not be invoked for components using the new APIs. |
| 18546 | |
| 18547 | if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) { |
| 18548 | if (unresolvedOldProps !== unresolvedNewProps || oldContext !== nextContext) { |
| 18549 | callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext); |
| 18550 | } |
| 18551 | } |
| 18552 | |
| 18553 | resetHasForceUpdateBeforeProcessing(); |
| 18554 | var oldState = workInProgress.memoizedState; |
| 18555 | var newState = instance.state = oldState; |
| 18556 | processUpdateQueue(workInProgress, newProps, instance, renderLanes); |
| 18557 | newState = workInProgress.memoizedState; |
| 18558 | |
| 18559 | if (unresolvedOldProps === unresolvedNewProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing() && !(enableLazyContextPropagation )) { |
| 18560 | // If an update was already in progress, we should schedule an Update |
| 18561 | // effect even though we're bailing out, so that cWU/cDU are called. |
| 18562 | if (typeof instance.componentDidUpdate === 'function') { |
| 18563 | if (unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState) { |
| 18564 | workInProgress.flags |= Update; |
| 18565 | } |
| 18566 | } |
| 18567 | |
| 18568 | if (typeof instance.getSnapshotBeforeUpdate === 'function') { |
| 18569 | if (unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState) { |
| 18570 | workInProgress.flags |= Snapshot; |
| 18571 | } |
| 18572 | } |
| 18573 | |
| 18574 | return false; |
| 18575 | } |
| 18576 | |
| 18577 | if (typeof getDerivedStateFromProps === 'function') { |
| 18578 | applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps); |
| 18579 | newState = workInProgress.memoizedState; |
no test coverage detected
searching dependent graphs…