(current, workInProgress, renderExpirationTime)
| 8921 | |
| 8922 | // Invokes the update life-cycles and returns false if it shouldn't rerender. |
| 8923 | function updateClassInstance(current, workInProgress, renderExpirationTime) { |
| 8924 | var ctor = workInProgress.type; |
| 8925 | var instance = workInProgress.stateNode; |
| 8926 | resetInputPointers(workInProgress, instance); |
| 8927 | |
| 8928 | var oldProps = workInProgress.memoizedProps; |
| 8929 | var newProps = workInProgress.pendingProps; |
| 8930 | var oldContext = instance.context; |
| 8931 | var newUnmaskedContext = getUnmaskedContext(workInProgress); |
| 8932 | var newContext = getMaskedContext(workInProgress, newUnmaskedContext); |
| 8933 | |
| 8934 | // Note: During these life-cycles, instance.props/instance.state are what |
| 8935 | // ever the previously attempted to render - not the "current". However, |
| 8936 | // during componentDidUpdate we pass the "current" props. |
| 8937 | |
| 8938 | // In order to support react-lifecycles-compat polyfilled components, |
| 8939 | // Unsafe lifecycles should not be invoked for any component with the new gDSFP. |
| 8940 | if ((typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function') && typeof ctor.getDerivedStateFromProps !== 'function') { |
| 8941 | if (oldProps !== newProps || oldContext !== newContext) { |
| 8942 | callComponentWillReceiveProps(workInProgress, instance, newProps, newContext); |
| 8943 | } |
| 8944 | } |
| 8945 | |
| 8946 | // Compute the next state using the memoized state and the update queue. |
| 8947 | var oldState = workInProgress.memoizedState; |
| 8948 | // TODO: Previous state can be null. |
| 8949 | var newState = void 0; |
| 8950 | var derivedStateFromCatch = void 0; |
| 8951 | if (workInProgress.updateQueue !== null) { |
| 8952 | newState = processUpdateQueue(current, workInProgress, workInProgress.updateQueue, instance, newProps, renderExpirationTime); |
| 8953 | |
| 8954 | var updateQueue = workInProgress.updateQueue; |
| 8955 | if (updateQueue !== null && updateQueue.capturedValues !== null && enableGetDerivedStateFromCatch && typeof ctor.getDerivedStateFromCatch === 'function') { |
| 8956 | var capturedValues = updateQueue.capturedValues; |
| 8957 | // Don't remove these from the update queue yet. We need them in |
| 8958 | // finishClassComponent. Do the reset there. |
| 8959 | // TODO: This is awkward. Refactor class components. |
| 8960 | // updateQueue.capturedValues = null; |
| 8961 | derivedStateFromCatch = callGetDerivedStateFromCatch(ctor, capturedValues); |
| 8962 | } |
| 8963 | } else { |
| 8964 | newState = oldState; |
| 8965 | } |
| 8966 | |
| 8967 | var derivedStateFromProps = void 0; |
| 8968 | if (oldProps !== newProps) { |
| 8969 | // The prevState parameter should be the partially updated state. |
| 8970 | // Otherwise, spreading state in return values could override updates. |
| 8971 | derivedStateFromProps = callGetDerivedStateFromProps(workInProgress, instance, newProps, newState); |
| 8972 | } |
| 8973 | |
| 8974 | if (derivedStateFromProps !== null && derivedStateFromProps !== undefined) { |
| 8975 | // Render-phase updates (like this) should not be added to the update queue, |
| 8976 | // So that multiple render passes do not enqueue multiple updates. |
| 8977 | // Instead, just synchronously merge the returned state into the instance. |
| 8978 | newState = newState === null || newState === undefined ? derivedStateFromProps : _assign({}, newState, derivedStateFromProps); |
| 8979 | } |
| 8980 | if (derivedStateFromCatch !== null && derivedStateFromCatch !== undefined) { |
no test coverage detected