@@ -149,6 +149,7 @@ const exclude = new Set([
149149 'dependencies' ,
150150 'destroy' ,
151151 'effects' ,
152+ 'element' ,
152153 'elementType' ,
153154 'firstBaseUpdate' ,
154155 'firstEffect' ,
@@ -158,18 +159,22 @@ const exclude = new Set([
158159 'lanes' ,
159160 'lastBaseUpdate' ,
160161 'lastEffect' ,
162+ 'navigator' ,
161163 'memoizedState' ,
162164 'mode' ,
163165 'next' ,
164166 'nextEffect' ,
165167 'pending' ,
166168 'parentSub' ,
169+ 'pathnameBase' ,
167170 'pendingProps' ,
168171 'Provider' ,
169172 'updateQueue' ,
170173 'ref' ,
171174 'responders' ,
172175 'return' ,
176+ 'route' ,
177+ 'routeContext' ,
173178 'shared' ,
174179 'sibling' ,
175180 'stateNode' ,
@@ -192,20 +197,26 @@ const exclude = new Set([
192197// This recursive function is used to grab the state of children components
193198// and push them into the parent componenent
194199// 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;
197202 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' ) {
199211 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 {
209220 newPropData [ key ] = newObj [ key ] ;
210221 }
211222 }
@@ -241,15 +252,25 @@ function createTree(
241252 dependencies,
242253 _debugHookTypes,
243254 } = 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+ } ) ;
244265
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
246267 if ( tag === 5 ) {
247268 try {
248269 // Ensure parent component has memoizedProps property
249270 if (
250271 memoizedProps . children &&
251272 memoizedProps . children [ 0 ] ?. _owner ?. memoizedProps !== undefined
252- ) {
273+ ) {
253274 // Access the memoizedProps of the parent component
254275 const propsData = memoizedProps . children [ 0 ] . _owner . memoizedProps ;
255276 const newPropData = convertDataToString (
@@ -281,13 +302,13 @@ function createTree(
281302 let componentFound = false ;
282303
283304 // 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 , { } ) ;
286307 }
287308
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 ) ;
291312 }
292313 // Check if node is a stateful class component
293314 if ( stateNode && stateNode . state && ( tag === 0 || tag === 1 || tag === 2 ) ) {
@@ -337,7 +358,7 @@ function createTree(
337358 selfBaseDuration,
338359 treeBaseDuration,
339360 } ;
340-
361+ console . log ( 'props' , componentData . props ) ;
341362 let newNode = null ;
342363
343364 // We want to add this fiber node to the snapshot
@@ -392,6 +413,7 @@ function createTree(
392413 circularComponentTable . add ( sibling ) ;
393414 createTree ( sibling , newNode , true ) ;
394415 }
416+
395417 return tree ;
396418}
397419/**
0 commit comments