(current$$1, finishedWork)
| 16922 | } |
| 16923 | |
| 16924 | function commitBeforeMutationLifeCycles(current$$1, finishedWork) { |
| 16925 | switch (finishedWork.tag) { |
| 16926 | case FunctionComponent: |
| 16927 | case ForwardRef: |
| 16928 | case SimpleMemoComponent: |
| 16929 | { |
| 16930 | commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork); |
| 16931 | return; |
| 16932 | } |
| 16933 | case ClassComponent: |
| 16934 | { |
| 16935 | if (finishedWork.effectTag & Snapshot) { |
| 16936 | if (current$$1 !== null) { |
| 16937 | var prevProps = current$$1.memoizedProps; |
| 16938 | var prevState = current$$1.memoizedState; |
| 16939 | startPhaseTimer(finishedWork, 'getSnapshotBeforeUpdate'); |
| 16940 | var instance = finishedWork.stateNode; |
| 16941 | // We could update instance props and state here, |
| 16942 | // but instead we rely on them being set during last render. |
| 16943 | // TODO: revisit this when we implement resuming. |
| 16944 | { |
| 16945 | if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) { |
| 16946 | !(instance.props === finishedWork.memoizedProps) ? warning$1(false, 'Expected %s props to match memoized props before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0; |
| 16947 | !(instance.state === finishedWork.memoizedState) ? warning$1(false, 'Expected %s state to match memoized state before ' + 'getSnapshotBeforeUpdate. ' + 'This might either be because of a bug in React, or because ' + 'a component reassigns its own `this.props`. ' + 'Please file an issue.', getComponentName(finishedWork.type) || 'instance') : void 0; |
| 16948 | } |
| 16949 | } |
| 16950 | var snapshot = instance.getSnapshotBeforeUpdate(finishedWork.elementType === finishedWork.type ? prevProps : resolveDefaultProps(finishedWork.type, prevProps), prevState); |
| 16951 | { |
| 16952 | var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate; |
| 16953 | if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) { |
| 16954 | didWarnSet.add(finishedWork.type); |
| 16955 | warningWithoutStack$1(false, '%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' + 'must be returned. You have returned undefined.', getComponentName(finishedWork.type)); |
| 16956 | } |
| 16957 | } |
| 16958 | instance.__reactInternalSnapshotBeforeUpdate = snapshot; |
| 16959 | stopPhaseTimer(); |
| 16960 | } |
| 16961 | } |
| 16962 | return; |
| 16963 | } |
| 16964 | case HostRoot: |
| 16965 | case HostComponent: |
| 16966 | case HostText: |
| 16967 | case HostPortal: |
| 16968 | case IncompleteClassComponent: |
| 16969 | // Nothing to do for these component types |
| 16970 | return; |
| 16971 | default: |
| 16972 | { |
| 16973 | invariant(false, 'This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.'); |
| 16974 | } |
| 16975 | } |
| 16976 | } |
| 16977 | |
| 16978 | function commitHookEffectList(unmountTag, mountTag, finishedWork) { |
| 16979 | if (!enableHooks) { |
no test coverage detected