(current, workInProgress, ctor, newProps, renderExpirationTime)
| 16846 | |
| 16847 | |
| 16848 | function updateClassInstance(current, workInProgress, ctor, newProps, renderExpirationTime) { |
| 16849 | var instance = workInProgress.stateNode; |
| 16850 | cloneUpdateQueue(current, workInProgress); |
| 16851 | var oldProps = workInProgress.memoizedProps; |
| 16852 | instance.props = workInProgress.type === workInProgress.elementType ? oldProps : resolveDefaultProps(workInProgress.type, oldProps); |
| 16853 | var oldContext = instance.context; |
| 16854 | var contextType = ctor.contextType; |
| 16855 | var nextContext = emptyContextObject; |
| 16856 | |
| 16857 | if (typeof contextType === 'object' && contextType !== null) { |
| 16858 | nextContext = readContext(contextType); |
| 16859 | } else { |
| 16860 | var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true); |
| 16861 | nextContext = getMaskedContext(workInProgress, nextUnmaskedContext); |
| 16862 | } |
| 16863 | |
| 16864 | var getDerivedStateFromProps = ctor.getDerivedStateFromProps; |
| 16865 | var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what |
| 16866 | // ever the previously attempted to render - not the "current". However, |
| 16867 | // during componentDidUpdate we pass the "current" props. |
| 16868 | // In order to support react-lifecycles-compat polyfilled components, |
| 16869 | // Unsafe lifecycles should not be invoked for components using the new APIs. |
| 16870 | |
| 16871 | if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) { |
| 16872 | if (oldProps !== newProps || oldContext !== nextContext) { |
| 16873 | callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext); |
| 16874 | } |
| 16875 | } |
| 16876 | |
| 16877 | resetHasForceUpdateBeforeProcessing(); |
| 16878 | var oldState = workInProgress.memoizedState; |
| 16879 | var newState = instance.state = oldState; |
| 16880 | processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); |
| 16881 | newState = workInProgress.memoizedState; |
| 16882 | |
| 16883 | if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) { |
| 16884 | // If an update was already in progress, we should schedule an Update |
| 16885 | // effect even though we're bailing out, so that cWU/cDU are called. |
| 16886 | if (typeof instance.componentDidUpdate === 'function') { |
| 16887 | if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) { |
| 16888 | workInProgress.effectTag |= Update; |
| 16889 | } |
| 16890 | } |
| 16891 | |
| 16892 | if (typeof instance.getSnapshotBeforeUpdate === 'function') { |
| 16893 | if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) { |
| 16894 | workInProgress.effectTag |= Snapshot; |
| 16895 | } |
| 16896 | } |
| 16897 | |
| 16898 | return false; |
| 16899 | } |
| 16900 | |
| 16901 | if (typeof getDerivedStateFromProps === 'function') { |
| 16902 | applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps); |
| 16903 | newState = workInProgress.memoizedState; |
| 16904 | } |
| 16905 |
no test coverage detected