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