@@ -79,7 +79,6 @@ export default function createTree(
7979 currentFiberNode : Fiber ,
8080 circularComponentTable : Set < Fiber > = new Set ( ) ,
8181 tree : Tree = new Tree ( 'root' , 'root' ) ,
82- fromSibling = false ,
8382) : Tree {
8483 // Base Case: if has visited the component, return
8584 if ( circularComponentTable . has ( currentFiberNode ) ) {
@@ -109,6 +108,7 @@ export default function createTree(
109108 elementType ?. render ?. name ||
110109 elementType ?. name ||
111110 'nameless' ;
111+ console . log ( 'createTree' , { tree } ) ;
112112 // console.log('LinkFiber', {
113113 // currentFiberNode,
114114 // // tag,
@@ -148,10 +148,6 @@ export default function createTree(
148148 context : { } ,
149149 } ;
150150 let isStatefulComponent = false ;
151- /**
152- * The updated tree after adding the `componentData` obtained from `currentFiberNode`
153- */
154- let newNode : Tree ;
155151
156152 // ----------------APPEND PROP DATA FROM REACT DEV TOOL-----------------------
157153 // check to see if the parent component has any state/props
@@ -295,6 +291,11 @@ export default function createTree(
295291 * `rtid` - The `Root ID` is a unique identifier that is assigned to each React root instance in a React application.
296292 */
297293 let rtid : string | null = null ;
294+ /**
295+ * The updated tree after adding the `componentData` obtained from `currentFiberNode`
296+ */
297+ let newNode : Tree = tree ;
298+ let parentNode : Tree ;
298299 // We want to add this fiber node to the snapshot
299300 if (
300301 ( isStatefulComponent || newState === 'stateless' ) &&
@@ -305,7 +306,7 @@ export default function createTree(
305306 rtid = `fromLinkFiber${ rtidCounter } ` ;
306307 // rtid = rtidCounter;
307308 // check if rtid is already present
308- // remove existing rtid before adding a new one
309+ // remove existing rtid before adding a new one
309310 if ( currentFiberNode . child . stateNode . classList . length > 0 ) {
310311 const lastClass =
311312 currentFiberNode . child . stateNode . classList [
@@ -318,14 +319,9 @@ export default function createTree(
318319 currentFiberNode . child . stateNode . classList . add ( rtid ) ;
319320 }
320321 rtidCounter += 1 ; // I THINK THIS SHOULD BE UP IN THE IF STATEMENT. Still unsure the use of rtid
321- // checking if tree fromSibling is true
322- if ( fromSibling ) {
323- newNode = tree . addSibling ( newState , componentName , componentData , rtid ) ;
324- } else {
325- newNode = tree . addChild ( newState , componentName , componentData , rtid ) ;
326- }
327- } else {
328- newNode = tree ;
322+
323+ // Append the childNode to the tree
324+ [ parentNode , newNode ] = tree . addChild ( newState , componentName , componentData , rtid ) ;
329325 }
330326
331327 // ----------------------TRAVERSE TO NEXT FIBERNODE---------------------------
@@ -334,12 +330,14 @@ export default function createTree(
334330
335331 // If currentFiberNode has siblings, recurse on siblings
336332 if ( sibling ) {
333+ // If the component was not filtered, add the sibling to the parentNode
337334 if (
338335 ( isStatefulComponent || newState === 'stateless' ) &&
339336 ! nextJSDefaultComponent . has ( componentName )
340337 )
341- createTree ( sibling , circularComponentTable , newNode , true ) ;
342- else createTree ( sibling , circularComponentTable , newNode , fromSibling ) ;
338+ createTree ( sibling , circularComponentTable , parentNode ) ;
339+
340+ else createTree ( sibling , circularComponentTable , newNode ) ;
343341 }
344342
345343 // -------------RETURN THE TREE OUTPUT & PASS TO FRONTEND FOR RENDERING-------
0 commit comments