@@ -77,6 +77,7 @@ function sendSnapshot(snap: Snapshot, mode: Mode): void {
7777 } ,
7878 '*' ,
7979 ) ;
80+ console . log ( 'LinkFiber' , { payload } ) ;
8081}
8182
8283/**
@@ -149,6 +150,7 @@ const exclude = new Set([
149150 'dependencies' ,
150151 'destroy' ,
151152 'effects' ,
153+ 'element' ,
152154 'elementType' ,
153155 'firstBaseUpdate' ,
154156 'firstEffect' ,
@@ -158,18 +160,22 @@ const exclude = new Set([
158160 'lanes' ,
159161 'lastBaseUpdate' ,
160162 'lastEffect' ,
163+ 'navigator' ,
161164 'memoizedState' ,
162165 'mode' ,
163166 'next' ,
164167 'nextEffect' ,
165168 'pending' ,
166169 'parentSub' ,
170+ 'pathnameBase' ,
167171 'pendingProps' ,
168172 'Provider' ,
169173 'updateQueue' ,
170174 'ref' ,
171175 'responders' ,
172176 'return' ,
177+ 'route' ,
178+ 'routeContext' ,
173179 'shared' ,
174180 'sibling' ,
175181 'stateNode' ,
@@ -192,20 +198,26 @@ const exclude = new Set([
192198// This recursive function is used to grab the state of children components
193199// and push them into the parent componenent
194200// 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;
197203 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' ) {
199212 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 {
209221 newPropData [ key ] = newObj [ key ] ;
210222 }
211223 }
@@ -241,15 +253,25 @@ function createTree(
241253 dependencies,
242254 _debugHookTypes,
243255 } = 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+ } ) ;
244266
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
246268 if ( tag === 5 ) {
247269 try {
248270 // Ensure parent component has memoizedProps property
249271 if (
250272 memoizedProps . children &&
251273 memoizedProps . children [ 0 ] ?. _owner ?. memoizedProps !== undefined
252- ) {
274+ ) {
253275 // Access the memoizedProps of the parent component
254276 const propsData = memoizedProps . children [ 0 ] . _owner . memoizedProps ;
255277 const newPropData = convertDataToString (
@@ -281,13 +303,13 @@ function createTree(
281303 let componentFound = false ;
282304
283305 // 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 , { } ) ;
286308 }
287309
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 ) ;
291313 }
292314 // Check if node is a stateful class component
293315 if ( stateNode && stateNode . state && ( tag === 0 || tag === 1 || tag === 2 ) ) {
@@ -337,7 +359,7 @@ function createTree(
337359 selfBaseDuration,
338360 treeBaseDuration,
339361 } ;
340-
362+ console . log ( 'props' , componentData . props ) ;
341363 let newNode = null ;
342364
343365 // We want to add this fiber node to the snapshot
@@ -392,6 +414,7 @@ function createTree(
392414 circularComponentTable . add ( sibling ) ;
393415 createTree ( sibling , newNode , true ) ;
394416 }
417+
395418 return tree ;
396419}
397420/**
0 commit comments