@@ -46,14 +46,15 @@ module.exports = (snap, mode) => {
46
46
47
47
function changeUseState ( component ) {
48
48
if ( component . queue . dispatch . linkFiberChanged ) return ;
49
- // store the original dispatch function definition
50
- const oldDispatch = component . queue . dispatch . bind ( component . queue ) ; ;
49
+ // store the original dispatch function definition
50
+ const oldDispatch = component . queue . dispatch . bind ( component . queue ) ;
51
51
// redefine the dispatch function so we can inject our code
52
52
component . queue . dispatch = ( fiber , queue , action ) => {
53
53
// don't do anything if state is locked
54
54
if ( mode . locked && ! mode . jumping ) return ;
55
- oldDispatch ( fiber , queue , action ) ;
55
+ // oldDispatch(fiber, queue, action);
56
56
setTimeout ( ( ) => {
57
+ oldDispatch ( fiber , queue , action ) ;
57
58
updateSnapShotTree ( ) ;
58
59
sendSnapshot ( ) ;
59
60
} , 100 ) ;
@@ -99,7 +100,7 @@ module.exports = (snap, mode) => {
99
100
changeSetState ( stateNode ) ;
100
101
}
101
102
// Check if the component uses hooks
102
- if ( memoizedState && memoizedState . hasOwnProperty ( 'baseState' ) ) {
103
+ if ( memoizedState && memoizedState . hasOwnProperty ( 'baseState' ) ) {
103
104
// Add a traversed property and initialize to the evaluated result
104
105
// of invoking traverseHooks, and reassign nextTree
105
106
memoizedState . traversed = traverseHooks ( memoizedState ) ;
@@ -112,7 +113,8 @@ module.exports = (snap, mode) => {
112
113
113
114
return tree ;
114
115
}
115
-
116
+ // runs when page initially loads
117
+ // but skips 1st hook click
116
118
function updateSnapShotTree ( ) {
117
119
const { current } = fiberRoot ;
118
120
snap . tree = createTree ( current ) ;
@@ -131,7 +133,7 @@ module.exports = (snap, mode) => {
131
133
astHooks = astParser ( entryFile ) ;
132
134
saveState ( astHooks ) ;
133
135
}
134
- updateSnapShotTree ( ) ;
136
+ updateSnapShotTree ( ) ;
135
137
// send the initial snapshot once the content script has started up
136
138
window . addEventListener ( 'message' , ( { data : { action } } ) => {
137
139
if ( action === 'contentScriptStarted' ) sendSnapshot ( ) ;
0 commit comments