(current, workInProgress, renderExpirationTime)
| 8000 | |
| 8001 | // Invokes the update life-cycles and returns false if it shouldn't rerender. |
| 8002 | function updateClassInstance(current, workInProgress, renderExpirationTime) { |
| 8003 | var ctor = workInProgress.type; |
| 8004 | var instance = workInProgress.stateNode; |
| 8005 | resetInputPointers(workInProgress, instance); |
| 8006 | |
| 8007 | var oldProps = workInProgress.memoizedProps; |
| 8008 | var newProps = workInProgress.pendingProps; |
| 8009 | var oldContext = instance.context; |
| 8010 | var newUnmaskedContext = getUnmaskedContext(workInProgress); |
| 8011 | var newContext = getMaskedContext(workInProgress, newUnmaskedContext); |
| 8012 | |
| 8013 | // Note: During these life-cycles, instance.props/instance.state are what |
| 8014 | // ever the previously attempted to render - not the "current". However, |
| 8015 | // during componentDidUpdate we pass the "current" props. |
| 8016 | |
| 8017 | // In order to support react-lifecycles-compat polyfilled components, |
| 8018 | // Unsafe lifecycles should not be invoked for any component with the new gDSFP. |
| 8019 | if ((typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function') && typeof ctor.getDerivedStateFromProps !== 'function') { |
| 8020 | if (oldProps !== newProps || oldContext !== newContext) { |
| 8021 | callComponentWillReceiveProps(workInProgress, instance, newProps, newContext); |
| 8022 | } |
| 8023 | } |
| 8024 | |
| 8025 | // Compute the next state using the memoized state and the update queue. |
| 8026 | var oldState = workInProgress.memoizedState; |
| 8027 | // TODO: Previous state can be null. |
| 8028 | var newState = void 0; |
| 8029 | var derivedStateFromCatch = void 0; |
| 8030 | if (workInProgress.updateQueue !== null) { |
| 8031 | newState = processUpdateQueue(current, workInProgress, workInProgress.updateQueue, instance, newProps, renderExpirationTime); |
| 8032 | |
| 8033 | var updateQueue = workInProgress.updateQueue; |
| 8034 | if (updateQueue !== null && updateQueue.capturedValues !== null && enableGetDerivedStateFromCatch && typeof ctor.getDerivedStateFromCatch === 'function') { |
| 8035 | var capturedValues = updateQueue.capturedValues; |
| 8036 | // Don't remove these from the update queue yet. We need them in |
| 8037 | // finishClassComponent. Do the reset there. |
| 8038 | // TODO: This is awkward. Refactor class components. |
| 8039 | // updateQueue.capturedValues = null; |
| 8040 | derivedStateFromCatch = callGetDerivedStateFromCatch(ctor, capturedValues); |
| 8041 | } |
| 8042 | } else { |
| 8043 | newState = oldState; |
| 8044 | } |
| 8045 | |
| 8046 | var derivedStateFromProps = void 0; |
| 8047 | if (oldProps !== newProps) { |
| 8048 | // The prevState parameter should be the partially updated state. |
| 8049 | // Otherwise, spreading state in return values could override updates. |
| 8050 | derivedStateFromProps = callGetDerivedStateFromProps(workInProgress, instance, newProps, newState); |
| 8051 | } |
| 8052 | |
| 8053 | if (derivedStateFromProps !== null && derivedStateFromProps !== undefined) { |
| 8054 | // Render-phase updates (like this) should not be added to the update queue, |
| 8055 | // So that multiple render passes do not enqueue multiple updates. |
| 8056 | // Instead, just synchronously merge the returned state into the instance. |
| 8057 | newState = newState === null || newState === undefined ? derivedStateFromProps : _assign({}, newState, derivedStateFromProps); |
| 8058 | } |
| 8059 | if (derivedStateFromCatch !== null && derivedStateFromCatch !== undefined) { |
no test coverage detected