@@ -70,20 +70,25 @@ module.exports = (snap, mode) => {
70
70
let index = 0 ;
71
71
astHooks = Object . values ( astHooks ) ;
72
72
// while memoizedState is truthy, save the value to the object
73
- while ( memoizedState && memoizedState . queue ) {
73
+ while ( memoizedState && memoizedState . queue ) { // prevents useEffect from crashing on load
74
+ // if (memoizedState.next.queue === null) { // prevents double pushing snapshot updates
74
75
changeUseState ( memoizedState ) ;
75
-
76
+ // }
77
+ // memoized[astHooks[index]] = memoizedState.memoizedState;
76
78
memoized [ astHooks [ index ] ] = memoizedState . memoizedState ;
77
79
// Reassign memoizedState to its next value
78
80
memoizedState = memoizedState . next ;
79
- index += 2 ; // Increment the index by 2
81
+ // Increment the index by 2
82
+ index += 2 ;
80
83
}
81
84
return memoized ;
82
85
}
83
86
84
87
function createTree ( currentFiber , tree = new Tree ( 'root' ) ) {
85
88
if ( ! currentFiber ) return tree ;
86
89
90
+ // console.log("currentFiber", currentFiber);
91
+
87
92
const {
88
93
sibling,
89
94
stateNode,
@@ -101,10 +106,11 @@ module.exports = (snap, mode) => {
101
106
changeSetState ( stateNode ) ;
102
107
}
103
108
// Check if the component uses hooks
104
- if (
105
- memoizedState
106
- && Object . hasOwnProperty . call ( memoizedState , 'baseState' )
107
- ) {
109
+ // console.log("memoizedState", memoizedState);
110
+
111
+ if ( memoizedState && Object . hasOwnProperty . call ( memoizedState , 'baseState' ) ) {
112
+ // 'catch-all' for suspense elements (experimental)
113
+ if ( typeof elementType . $$typeof === 'symbol' ) return ;
108
114
// Traverse through the currentFiber and extract the getters/setters
109
115
astHooks = astParser ( elementType ) ;
110
116
saveState ( astHooks ) ;
@@ -135,6 +141,7 @@ module.exports = (snap, mode) => {
135
141
// only assign internal rootp if it actually exists
136
142
fiberRoot = _internalRoot || _reactRootContainer ;
137
143
144
+
138
145
updateSnapShotTree ( ) ;
139
146
// send the initial snapshot once the content script has started up
140
147
window . addEventListener ( 'message' , ( { data : { action } } ) => {
0 commit comments