@@ -77,6 +77,7 @@ function sendSnapshot(snap: Snapshot, mode: Mode): void {
77
77
} ,
78
78
'*' ,
79
79
) ;
80
+ console . log ( 'LinkFiber' , { payload } ) ;
80
81
}
81
82
82
83
/**
@@ -149,6 +150,7 @@ const exclude = new Set([
149
150
'dependencies' ,
150
151
'destroy' ,
151
152
'effects' ,
153
+ 'element' ,
152
154
'elementType' ,
153
155
'firstBaseUpdate' ,
154
156
'firstEffect' ,
@@ -158,18 +160,22 @@ const exclude = new Set([
158
160
'lanes' ,
159
161
'lastBaseUpdate' ,
160
162
'lastEffect' ,
163
+ 'navigator' ,
161
164
'memoizedState' ,
162
165
'mode' ,
163
166
'next' ,
164
167
'nextEffect' ,
165
168
'pending' ,
166
169
'parentSub' ,
170
+ 'pathnameBase' ,
167
171
'pendingProps' ,
168
172
'Provider' ,
169
173
'updateQueue' ,
170
174
'ref' ,
171
175
'responders' ,
172
176
'return' ,
177
+ 'route' ,
178
+ 'routeContext' ,
173
179
'shared' ,
174
180
'sibling' ,
175
181
'stateNode' ,
@@ -192,20 +198,26 @@ const exclude = new Set([
192
198
// This recursive function is used to grab the state of children components
193
199
// and push them into the parent componenent
194
200
// react elements throw errors on client side of application - convert react/functions into string
195
- function convertDataToString ( newObj , oldObj , depth = 0 ) {
196
- const newPropData = oldObj || { } ;
201
+ function convertDataToString ( newObj , newPropData = { } , depth = 0 ) {
202
+ // const newPropData = oldObj;
197
203
for ( const key in newObj ) {
198
- if ( typeof newObj [ key ] === 'function' ) {
204
+ // Skip keys that are in exclude list OR if there is no value at key
205
+ if ( exclude . has ( key ) || ! newObj [ key ] ) {
206
+ continue ;
207
+ // newPropData[key] = 'reactFiber';
208
+ // return newPropData;
209
+ }
210
+ // If value at key is a function, assign key with value 'function' to newPropData object
211
+ else if ( typeof newObj [ key ] === 'function' ) {
199
212
newPropData [ key ] = 'function' ;
200
- } else if ( exclude . has ( key ) ) {
201
- newPropData [ key ] = 'reactFiber' ;
202
- return newPropData ;
203
- } else if ( typeof newObj [ key ] === 'object' && ! exclude . has ( key ) ) {
204
- newPropData [ key ] =
205
- depth > 10
206
- ? 'convertDataToString reached max depth'
207
- : convertDataToString ( newObj [ key ] , null , depth + 1 ) ;
208
- } else if ( ! exclude . has ( key ) ) {
213
+ }
214
+ // If value at key is an object, recusive call convertDataToString to traverse through all keys and append to newPropData object accodingly
215
+ else if ( typeof newObj [ key ] === 'object' ) {
216
+ // newPropData[key] =
217
+ depth > 10
218
+ ? 'convertDataToString reached max depth'
219
+ : convertDataToString ( newObj [ key ] , newPropData , depth + 1 ) ;
220
+ } else {
209
221
newPropData [ key ] = newObj [ key ] ;
210
222
}
211
223
}
@@ -241,15 +253,25 @@ function createTree(
241
253
dependencies,
242
254
_debugHookTypes,
243
255
} = currentFiber ;
256
+ console . log ( 'LinkFiber' , {
257
+ tag,
258
+ elementType :
259
+ elementType ?. _context ?. displayName ||
260
+ elementType ?. render ?. name ||
261
+ elementType ?. name ||
262
+ elementType ,
263
+ memoizedProps,
264
+ memoizedState,
265
+ } ) ;
244
266
245
- // Tag === 5 signify this is a React Fragment. Each JSX component return a React fragment
267
+ // 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
246
268
if ( tag === 5 ) {
247
269
try {
248
270
// Ensure parent component has memoizedProps property
249
271
if (
250
272
memoizedProps . children &&
251
273
memoizedProps . children [ 0 ] ?. _owner ?. memoizedProps !== undefined
252
- ) {
274
+ ) {
253
275
// Access the memoizedProps of the parent component
254
276
const propsData = memoizedProps . children [ 0 ] . _owner . memoizedProps ;
255
277
const newPropData = convertDataToString (
@@ -281,13 +303,13 @@ function createTree(
281
303
let componentFound = false ;
282
304
283
305
// check to see if the parent component has any state/props
284
- if ( memoizedProps ) {
285
- componentData . props = convertDataToString ( memoizedProps , null ) ;
306
+ if ( memoizedProps && Object . keys ( memoizedProps ) . length ) {
307
+ componentData . props = convertDataToString ( memoizedProps , { } ) ;
286
308
}
287
309
288
- // if the component uses the useContext hook, we want to grab the co text object and add it to the componentData object for that fiber
289
- if ( tag === 0 && _debugHookTypes ) {
290
- componentData . context = convertDataToString ( dependencies ? .firstContext ? .memoizedValue , null ) ;
310
+ // if the component uses the useContext hook, we want to grab the context object and add it to the componentData object for that fiber
311
+ if ( tag === 0 && _debugHookTypes && dependencies ?. firstContext ?. memoizedValue ) {
312
+ componentData . context = convertDataToString ( dependencies . firstContext . memoizedValue , null ) ;
291
313
}
292
314
// Check if node is a stateful class component
293
315
if ( stateNode && stateNode . state && ( tag === 0 || tag === 1 || tag === 2 ) ) {
@@ -337,7 +359,7 @@ function createTree(
337
359
selfBaseDuration,
338
360
treeBaseDuration,
339
361
} ;
340
-
362
+ console . log ( 'props' , componentData . props ) ;
341
363
let newNode = null ;
342
364
343
365
// We want to add this fiber node to the snapshot
@@ -392,6 +414,7 @@ function createTree(
392
414
circularComponentTable . add ( sibling ) ;
393
415
createTree ( sibling , newNode , true ) ;
394
416
}
417
+
395
418
return tree ;
396
419
}
397
420
/**
0 commit comments