(current, workInProgress, renderExpirationTime)
| 8763 | |
| 8764 | // Invokes the update life-cycles and returns false if it shouldn't rerender. |
| 8765 | function updateClassInstance(current, workInProgress, renderExpirationTime) { |
| 8766 | var ctor = workInProgress.type; |
| 8767 | var instance = workInProgress.stateNode; |
| 8768 | resetInputPointers(workInProgress, instance); |
| 8769 | |
| 8770 | var oldProps = workInProgress.memoizedProps; |
| 8771 | var newProps = workInProgress.pendingProps; |
| 8772 | var oldContext = instance.context; |
| 8773 | var newUnmaskedContext = getUnmaskedContext(workInProgress); |
| 8774 | var newContext = getMaskedContext(workInProgress, newUnmaskedContext); |
| 8775 | |
| 8776 | // Note: During these life-cycles, instance.props/instance.state are what |
| 8777 | // ever the previously attempted to render - not the "current". However, |
| 8778 | // during componentDidUpdate we pass the "current" props. |
| 8779 | |
| 8780 | // In order to support react-lifecycles-compat polyfilled components, |
| 8781 | // Unsafe lifecycles should not be invoked for any component with the new gDSFP. |
| 8782 | if ((typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function') && typeof ctor.getDerivedStateFromProps !== 'function') { |
| 8783 | if (oldProps !== newProps || oldContext !== newContext) { |
| 8784 | callComponentWillReceiveProps(workInProgress, instance, newProps, newContext); |
| 8785 | } |
| 8786 | } |
| 8787 | |
| 8788 | // Compute the next state using the memoized state and the update queue. |
| 8789 | var oldState = workInProgress.memoizedState; |
| 8790 | // TODO: Previous state can be null. |
| 8791 | var newState = void 0; |
| 8792 | var derivedStateFromCatch = void 0; |
| 8793 | if (workInProgress.updateQueue !== null) { |
| 8794 | newState = processUpdateQueue(current, workInProgress, workInProgress.updateQueue, instance, newProps, renderExpirationTime); |
| 8795 | |
| 8796 | var updateQueue = workInProgress.updateQueue; |
| 8797 | if (updateQueue !== null && updateQueue.capturedValues !== null && enableGetDerivedStateFromCatch && typeof ctor.getDerivedStateFromCatch === 'function') { |
| 8798 | var capturedValues = updateQueue.capturedValues; |
| 8799 | // Don't remove these from the update queue yet. We need them in |
| 8800 | // finishClassComponent. Do the reset there. |
| 8801 | // TODO: This is awkward. Refactor class components. |
| 8802 | // updateQueue.capturedValues = null; |
| 8803 | derivedStateFromCatch = callGetDerivedStateFromCatch(ctor, capturedValues); |
| 8804 | } |
| 8805 | } else { |
| 8806 | newState = oldState; |
| 8807 | } |
| 8808 | |
| 8809 | var derivedStateFromProps = void 0; |
| 8810 | if (oldProps !== newProps) { |
| 8811 | // The prevState parameter should be the partially updated state. |
| 8812 | // Otherwise, spreading state in return values could override updates. |
| 8813 | derivedStateFromProps = callGetDerivedStateFromProps(workInProgress, instance, newProps, newState); |
| 8814 | } |
| 8815 | |
| 8816 | if (derivedStateFromProps !== null && derivedStateFromProps !== undefined) { |
| 8817 | // Render-phase updates (like this) should not be added to the update queue, |
| 8818 | // So that multiple render passes do not enqueue multiple updates. |
| 8819 | // Instead, just synchronously merge the returned state into the instance. |
| 8820 | newState = newState === null || newState === undefined ? derivedStateFromProps : _assign({}, newState, derivedStateFromProps); |
| 8821 | } |
| 8822 | if (derivedStateFromCatch !== null && derivedStateFromCatch !== undefined) { |
no test coverage detected