You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/backend/linkFiber.ts
+79-19Lines changed: 79 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -16,12 +16,42 @@ import {
16
16
// tree
17
17
Snapshot,
18
18
// jump, pause
19
-
Mode,
19
+
Status,
20
20
// array of state and component
21
21
HookStates,
22
22
// object with tree structure
23
23
Fiber,
24
24
}from'./types/backendTypes';
25
+
import{
26
+
FunctionComponent,
27
+
ClassComponent,
28
+
IndeterminateComponent,// Before we know whether it is function or class
29
+
HostRoot,// Root of a host tree. Could be nested inside another node.
30
+
HostPortal,// A subtree. Could be an entry point to a different renderer.
31
+
/**
32
+
* Host Component: a type of component that represents a native DOM element in the browser environment, such as div, span, input, h1 etc.
33
+
*/
34
+
HostComponent,// has stateNode of html elements
35
+
HostText,
36
+
Fragment,
37
+
Mode,
38
+
ContextConsumer,
39
+
ContextProvider,
40
+
ForwardRef,
41
+
Profiler,
42
+
SuspenseComponent,
43
+
MemoComponent,
44
+
SimpleMemoComponent,// A higher order component where if the component renders the same result given the same props, react skips rendering the component and uses last rendered result. Has memoizedProps/memoizedState but no stateNode
45
+
LazyComponent,
46
+
IncompleteClassComponent,
47
+
DehydratedFragment,
48
+
SuspenseListComponent,
49
+
FundamentalComponent,
50
+
ScopeComponent,
51
+
Block,
52
+
OffscreenComponent,
53
+
LegacyHiddenComponent,
54
+
}from'./types/backendTypes';
25
55
// import function that creates a tree
26
56
importTreefrom'./tree';
27
57
// passes the data down to its components
@@ -54,7 +84,7 @@ let rtid = null;
54
84
*
55
85
* Middleware: Gets a copy of the current snap.tree and posts a recordSnap message to the window
// this is the currently active root fiber(the mutable root of the tree)
92
122
if(fiberRoot){
93
123
const{ current }=fiberRoot;
@@ -138,6 +168,7 @@ function traverseHooks(memoizedState: any): HookStates {
138
168
// This runs after every Fiber commit. It creates a new snapshot
139
169
constexclude=newSet([
140
170
'alternate',
171
+
'basename',
141
172
'baseQueue',
142
173
'baseState',
143
174
'child',
@@ -149,20 +180,25 @@ const exclude = new Set([
149
180
'deps',
150
181
'dependencies',
151
182
'destroy',
183
+
'dispatch',
184
+
'location',
152
185
'effects',
153
186
'element',
154
187
'elementType',
155
188
'firstBaseUpdate',
156
189
'firstEffect',
157
190
'flags',
158
191
'get key',
192
+
'getState',
159
193
'key',
160
194
'lanes',
161
195
'lastBaseUpdate',
162
196
'lastEffect',
197
+
'liftedStore',
163
198
'navigator',
164
199
'memoizedState',
165
200
'mode',
201
+
'navigationType',
166
202
'next',
167
203
'nextEffect',
168
204
'pending',
@@ -172,12 +208,15 @@ const exclude = new Set([
172
208
'Provider',
173
209
'updateQueue',
174
210
'ref',
211
+
'replaceReducer',
175
212
'responders',
176
213
'return',
177
214
'route',
178
215
'routeContext',
179
216
'shared',
180
217
'sibling',
218
+
'subscribe',
219
+
'subscription',
181
220
'stateNode',
182
221
'tag',
183
222
'type',
@@ -193,6 +232,7 @@ const exclude = new Set([
193
232
'_store',
194
233
'_threadCount',
195
234
'$$typeof',
235
+
'@@observable',
196
236
]);
197
237
// -----------------TRIMMING PASSED IN FIBER ROOT DATA--------------------------
198
238
/**
@@ -204,27 +244,37 @@ const exclude = new Set([
204
244
* @param depth - reactDevData is nested object. The value in reactDevData can be another object. Depth is use to keep track the depth during the unraveling of nested object
205
245
* @returns reactimeData - the updated data object to send to front end of ReactTime
// -------------------------CREATE TREE TO SEND TO FRONT END--------------------
229
279
/**
230
280
* Every time a state change is made in the accompanying app, the extension creates a Tree “snapshot” of the current state, and adds it to the current “cache” of snapshots in the extension
@@ -273,8 +323,8 @@ function createTree(
273
323
_debugHookTypes,
274
324
});
275
325
276
-
// Tag === 5 signify this is a React Fragment. Each JSX component return a React fragment => The parent of a React Fragment could be a JSX component
277
-
if(tag===5){
326
+
// TODO: Understand this if statement
327
+
if(tag===HostComponent){
278
328
try{
279
329
// Ensure parent component has memoizedProps property
280
330
if(
@@ -311,15 +361,24 @@ function createTree(
311
361
}={};
312
362
letcomponentFound=false;
313
363
364
+
/**
365
+
* In addition to React Component JSX from user input, there are other components that user would be using under the hood without needing to see it. For example, if Redux is used, a ContextProvider, called ReactRedux.Provider is created under the hood to manage the context store.
366
+
* @variable filteredComponents is boolean value, used to filter out 'under-the-hood' components
367
+
*/
368
+
// const filteredComponents = tag != ContextProvider;
369
+
constfilteredComponents=true;
314
370
// check to see if the parent component has any state/props
0 commit comments