(current, workInProgress, renderExpirationTime)
| 8705 | |
| 8706 | // Invokes the update life-cycles and returns false if it shouldn't rerender. |
| 8707 | function updateClassInstance(current, workInProgress, renderExpirationTime) { |
| 8708 | var ctor = workInProgress.type; |
| 8709 | var instance = workInProgress.stateNode; |
| 8710 | resetInputPointers(workInProgress, instance); |
| 8711 | |
| 8712 | var oldProps = workInProgress.memoizedProps; |
| 8713 | var newProps = workInProgress.pendingProps; |
| 8714 | var oldContext = instance.context; |
| 8715 | var newUnmaskedContext = getUnmaskedContext(workInProgress); |
| 8716 | var newContext = getMaskedContext(workInProgress, newUnmaskedContext); |
| 8717 | |
| 8718 | // Note: During these life-cycles, instance.props/instance.state are what |
| 8719 | // ever the previously attempted to render - not the "current". However, |
| 8720 | // during componentDidUpdate we pass the "current" props. |
| 8721 | |
| 8722 | // In order to support react-lifecycles-compat polyfilled components, |
| 8723 | // Unsafe lifecycles should not be invoked for any component with the new gDSFP. |
| 8724 | if ((typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function') && typeof ctor.getDerivedStateFromProps !== 'function') { |
| 8725 | if (oldProps !== newProps || oldContext !== newContext) { |
| 8726 | callComponentWillReceiveProps(workInProgress, instance, newProps, newContext); |
| 8727 | } |
| 8728 | } |
| 8729 | |
| 8730 | // Compute the next state using the memoized state and the update queue. |
| 8731 | var oldState = workInProgress.memoizedState; |
| 8732 | // TODO: Previous state can be null. |
| 8733 | var newState = void 0; |
| 8734 | var derivedStateFromCatch = void 0; |
| 8735 | if (workInProgress.updateQueue !== null) { |
| 8736 | newState = processUpdateQueue(current, workInProgress, workInProgress.updateQueue, instance, newProps, renderExpirationTime); |
| 8737 | |
| 8738 | var updateQueue = workInProgress.updateQueue; |
| 8739 | if (updateQueue !== null && updateQueue.capturedValues !== null && enableGetDerivedStateFromCatch && typeof ctor.getDerivedStateFromCatch === 'function') { |
| 8740 | var capturedValues = updateQueue.capturedValues; |
| 8741 | // Don't remove these from the update queue yet. We need them in |
| 8742 | // finishClassComponent. Do the reset there. |
| 8743 | // TODO: This is awkward. Refactor class components. |
| 8744 | // updateQueue.capturedValues = null; |
| 8745 | derivedStateFromCatch = callGetDerivedStateFromCatch(ctor, capturedValues); |
| 8746 | } |
| 8747 | } else { |
| 8748 | newState = oldState; |
| 8749 | } |
| 8750 | |
| 8751 | var derivedStateFromProps = void 0; |
| 8752 | if (oldProps !== newProps) { |
| 8753 | // The prevState parameter should be the partially updated state. |
| 8754 | // Otherwise, spreading state in return values could override updates. |
| 8755 | derivedStateFromProps = callGetDerivedStateFromProps(workInProgress, instance, newProps, newState); |
| 8756 | } |
| 8757 | |
| 8758 | if (derivedStateFromProps !== null && derivedStateFromProps !== undefined) { |
| 8759 | // Render-phase updates (like this) should not be added to the update queue, |
| 8760 | // So that multiple render passes do not enqueue multiple updates. |
| 8761 | // Instead, just synchronously merge the returned state into the instance. |
| 8762 | newState = newState === null || newState === undefined ? derivedStateFromProps : _assign({}, newState, derivedStateFromProps); |
| 8763 | } |
| 8764 | if (derivedStateFromCatch !== null && derivedStateFromCatch !== undefined) { |
no test coverage detected