@@ -45,11 +45,8 @@ module.exports = (snap, mode) => {
45
45
46
46
function changeUseState ( component ) {
47
47
if ( component . queue . dispatch . linkFiberChanged ) return ;
48
- // running the original useState and storing its result (state and dispatch function)
49
- const oldDispatch = component . queue . dispatch . bind ( component . queue ) ;
50
48
// storing the original dispatch function definition somewhere
51
- console . log ( 'inside changeusestate' , oldDispatch ) ;
52
-
49
+ const oldDispatch = component . queue . dispatch . bind ( component . queue ) ;
53
50
// redefining the dispatch function so we can inject our code
54
51
component . queue . dispatch = function ( fiber , queue , action ) {
55
52
console . log ( 'mode' , mode ) ;
@@ -102,6 +99,7 @@ module.exports = (snap, mode) => {
102
99
// TODO: Refactor the conditionals - think about the edge case where a stateful
103
100
// component might have a key called 'baseState' in the state
104
101
if ( memoizedState && memoizedState . hasOwnProperty ( 'baseState' ) ) {
102
+ console . log ( "I'm not supposed to run" , currentFiber ) ;
105
103
memoizedState . traversed = traverseHooks ( memoizedState ) ;
106
104
nextTree = tree . appendChild ( memoizedState ) ;
107
105
}
@@ -115,6 +113,7 @@ module.exports = (snap, mode) => {
115
113
116
114
function updateSnapShotTree ( ) {
117
115
const { current } = fiberRoot ;
116
+ console . log ( 'current' , current ) ;
118
117
snap . tree = createTree ( current ) ;
119
118
}
120
119
@@ -132,41 +131,5 @@ module.exports = (snap, mode) => {
132
131
if ( action === 'contentScriptStarted' ) sendSnapshot ( ) ;
133
132
} ) ;
134
133
} ,
135
- // testHooks(react) {
136
- // return {
137
- // useState: initialState => {
138
- // // running the original useState and storing its result (state and dispatch function)
139
- // const toReturn = react.useState(initialState);
140
- // // storing the original dispatch function definition somewhere
141
- // const oldDispatch = toReturn[1];
142
- // console.log('old dispatch', oldDispatch)
143
- // // redefining the dispatch function so we can inject our code
144
- // toReturn[1] = function (newVal) {
145
- // oldDispatch(newVal);
146
- // setTimeout(() => {
147
- // updateSnapShotTree();
148
- // sendSnapshot();
149
- // }, 100);
150
- // };
151
- // return toReturn;
152
- // },
153
- // useReducer: (reducer, initialState, init) => {
154
- // // Declare a constant and initialize to the built-in useReducer method
155
- // // Which returns an array with the state and dispatch
156
- // const reduced = react.useReducer(reducer, initialState, init);
157
- // // Save the dispatch method
158
- // const oldDispatch = reduced[1];
159
- // // reassign the dispatch method with the additional methods
160
- // reduced[1] = function (type) {
161
- // oldDispatch(type);
162
- // setTimeout(() => {
163
- // updateSnapShotTree();
164
- // sendSnapshot();
165
- // }, 100);
166
- // };
167
- // return reduced;
168
- // },
169
- // };
170
- // },
171
134
} ;
172
135
} ;
0 commit comments