@@ -116,8 +116,8 @@ module.exports = (snap, mode) => {
116116
117117 // Check if node is a stateful setState component
118118 if ( stateNode && stateNode . state && ( tag === 0 || tag === 1 ) ) {
119- console . log ( 'in create tree if' )
120- console . log ( 'this is currentFiber from createTree' , currentFiber )
119+ console . log ( 'in create tree if' ) ;
120+ console . log ( 'this is currentFiber from createTree' , currentFiber ) ;
121121 // Save component's state and setState() function to our record for future
122122 // time-travel state changing. Add record index to snapshot so we can retrieve.
123123 componentData . index = componentActionsRecord . saveNew ( stateNode . state , stateNode ) ;
@@ -128,8 +128,8 @@ module.exports = (snap, mode) => {
128128 // Check if node is a hooks useState function
129129 let hooksIndex ;
130130 if ( memoizedState && ( tag === 0 || tag === 1 || tag === 10 ) ) {
131- console . log ( 'in create tree if' )
132- console . log ( 'this is currentFiber from createTree' , currentFiber )
131+ console . log ( 'in create tree if' ) ;
132+ console . log ( 'this is currentFiber from createTree' , currentFiber ) ;
133133 if ( memoizedState . queue ) {
134134 // Hooks states are stored as a linked list using memoizedState.next,
135135 // so we must traverse through the list and get the states.
@@ -187,38 +187,6 @@ module.exports = (snap, mode) => {
187187 return tree ;
188188 }
189189
190-
191- // function createUnfilteredTree(curFiber, parentNode) {
192- // // on call from updateSnapShot, no parentNode provided, so create a root node
193- // if(! parentNode) parentNode = new Tree('root');
194-
195- // // Base case: parentNode's child or sibling pointed to null
196- // if (!curFiber) return parentNode;
197-
198- // let newChildNode = null;
199-
200- // // If stateful, add to parentNode's children array, then inject new setState into fiber node
201- // if (curFiber.stateNode && curFiber.stateNode.state) {
202- // newChildNode = parentNode.appendChild(curFiber.stateNode);
203- // // changeSetState(curFiber.stateNode);
204- // newChildNode.isStateful = true;
205- // }
206- // else {
207-
208- // }
209-
210- // // Recurse to sibling; siblings that have state should be added to our parentNode
211- // createTree(curFiber.sibling, parentNode);
212-
213- // // Recurse to child; If this fiber was stateful, then we added a newChildNode here, and we want
214- // // to attach further children to that. If this fiber wasn't stateful, we want to attach any
215- // // children to our existing parentNode.
216- // createTree(curFiber.child, newChildNode || parentNode);
217-
218- // return parentNode;
219- // }
220-
221-
222190 // ! BUG: skips 1st hook click
223191 function updateSnapShotTree ( ) {
224192 /* let current;
@@ -253,14 +221,14 @@ module.exports = (snap, mode) => {
253221 fiberRoot = _internalRoot || _reactRootContainer ;
254222 }
255223 const devTools = window . __REACT_DEVTOOLS_GLOBAL_HOOK__ ;
256- console . log ( 'this is devTools' , devTools )
224+ console . log ( 'this is devTools' , devTools ) ;
257225 const reactInstance = devTools ? devTools . renderers . get ( 1 ) : null ;
258226
259227 if ( reactInstance && reactInstance . version ) {
260228 devTools . onCommitFiberRoot = ( function ( original ) {
261229 return function ( ...args ) {
262230 fiberRoot = args [ 1 ] ;
263- console . log ( 'this is fiberRoot' , fiberRoot )
231+ console . log ( 'this is fiberRoot' , fiberRoot ) ;
264232 updateSnapShotTree ( ) ;
265233 sendSnapshot ( ) ;
266234 return original ( ...args ) ;
@@ -277,82 +245,3 @@ module.exports = (snap, mode) => {
277245 } ) ;
278246 } ;
279247} ;
280-
281-
282-
283-
284- // function createUnfilteredTree(currentFiber, tree = new Tree('root')) {
285- // // Base case: child or sibling pointed to null
286- // if (!currentFiber) return tree;
287-
288- // const { sibling, stateNode, child, memoizedState, elementType,
289- // tag, actualDuration, actualStartTime, selfBaseDuration, treeBaseDuration,
290- // } = currentFiber;
291-
292- // const extraProps = {
293- // tag, actualDuration, actualStartTime, selfBaseDuration, treeBaseDuration,
294- // };
295-
296- // let nextTree = tree;
297- // let nextTreeUnfiltered = unfilteredTreeNode = new UnfilteredTreeNode('root');
298-
299- // // Check if stateful component
300- // if (stateNode && stateNode.state) {
301- // nextTree = tree.appendChild(stateNode); // Add component to tree
302- // changeSetState(stateNode); // Change setState functionality
303- // }
304- // nextTreeUnfiltered = unfilteredTreeNode.appendChild(stateNode);
305-
306- // // TODO: handle Hooks cases...
307-
308- // // Recurse on siblings
309- // createTree(sibling, tree);
310- // // Recurse on children
311- // createTree(child, nextTree);
312-
313- // return tree;
314- // }
315-
316-
317-
318- // Check if the component uses hooks
319- // if (memoizedState && Object.hasOwnProperty.call(memoizedState, 'baseState')) {
320- // // 'catch-all' for suspense elements (experimental)
321- // if (typeof elementType.$$typeof === 'symbol') return;
322- // // Traverse through the currentFiber and extract the getters/setters
323- // astHooks = astParser(elementType);
324- // saveState(astHooks);
325- // // Create a traversed property and assign to the evaluated result of
326- // // invoking traverseHooks with memoizedState
327- // memoizedState.traversed = traverseHooks(memoizedState);
328- // nextTree = tree.appendChild(memoizedState);
329- // }
330-
331-
332-
333-
334-
335-
336-
337-
338- // function createTree(currentFiber, tree = new Tree('root')) {
339- // // Base case: child or sibling pointed to null
340- // if (!currentFiber) return tree;
341-
342- // const { sibling, stateNode, child, memoizedState, elementType } = currentFiber;
343-
344- // let nextTree = tree;
345-
346- // // Check if stateful component
347- // if (stateNode && stateNode.state) {
348- // nextTree = tree.appendChild(stateNode); // Add component to tree
349- // changeSetState(stateNode); // Change setState functionality
350- // }
351-
352- // // Recurse on siblings
353- // createTree(sibling, tree);
354- // // Recurse on children
355- // createTree(child, nextTree);
356-
357- // return tree;
358- // }
0 commit comments