/
ReactFiberUnwindWork.js
99 lines (95 loc) · 3.44 KB
/
ReactFiberUnwindWork.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import { HostRoot } from './ReactWorkTags';
import { popHostContainer } from './ReactFiberHostContext';
import { popTopLevelContextObject } from './ReactFiberContext';
import { resetWorkInProgressVersions } from './ReactMutableSource';
import { DidCapture, NoFlags, ShouldCapture } from './ReactFiberFlags';
const invariant = require('invariant');
const unwindInterruptedWork = (interruptedWork) => {};
const unwindWork = (workInProgress, renderLanes) => {
switch (workInProgress.tag) {
// case ClassComponent: {
// const Component = workInProgress.type;
// if (isLegacyContextProvider(Component)) {
// popLegacyContext(workInProgress);
// }
// const flags = workInProgress.flags;
// if (flags & ShouldCapture) {
// workInProgress.flags = (flags & ~ShouldCapture) | DidCapture;
// if (
// enableProfilerTimer &&
// (workInProgress.mode & ProfileMode) !== NoMode
// ) {
// transferActualDuration(workInProgress);
// }
// return workInProgress;
// }
// return null;
// }
case HostRoot: {
popHostContainer(workInProgress);
popTopLevelContextObject(workInProgress);
resetWorkInProgressVersions();
const flags = workInProgress.flags;
invariant(
(flags & DidCapture) === NoFlags,
'The root failed to unmount after an error. This is likely a bug in ' +
'React. Please file an issue.'
);
workInProgress.flags = (flags & ~ShouldCapture) | DidCapture;
console.log(flags, (flags & ~ShouldCapture) | DidCapture);
return workInProgress;
}
// case HostComponent: {
// // TODO: popHydrationState
// popHostContext(workInProgress);
// return null;
// }
// case SuspenseComponent: {
// popSuspenseContext(workInProgress);
// if (enableSuspenseServerRenderer) {
// const suspenseState: null | SuspenseState =
// workInProgress.memoizedState;
// if (suspenseState !== null && suspenseState.dehydrated !== null) {
// invariant(
// workInProgress.alternate !== null,
// 'Threw in newly mounted dehydrated component. This is likely a bug in ' +
// 'React. Please file an issue.',
// );
// resetHydrationState();
// }
// }
// const flags = workInProgress.flags;
// if (flags & ShouldCapture) {
// workInProgress.flags = (flags & ~ShouldCapture) | DidCapture;
// // Captured a suspense effect. Re-render the boundary.
// if (
// enableProfilerTimer &&
// (workInProgress.mode & ProfileMode) !== NoMode
// ) {
// transferActualDuration(workInProgress);
// }
// return workInProgress;
// }
// return null;
// }
// case SuspenseListComponent: {
// popSuspenseContext(workInProgress);
// // SuspenseList doesn't actually catch anything. It should've been
// // caught by a nested boundary. If not, it should bubble through.
// return null;
// }
// case HostPortal:
// popHostContainer(workInProgress);
// return null;
// case ContextProvider:
// popProvider(workInProgress);
// return null;
// case OffscreenComponent:
// case LegacyHiddenComponent:
// popRenderLanes(workInProgress);
// return null;
default:
return null;
}
};
export { unwindInterruptedWork, unwindWork };