You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
declarations[0]?.init?.callee?.expressions||//work for browser
143
-
(declarations[0]?.init?.arguments&&
144
-
declarations[0]?.init?.arguments[0]?.callee?.expressions);//work for jest test; Mark's notes: so this was where the app was breaking. ES6 functions inside functional components were hitting this line and crashing when it tried to access arguments[0] and arguments didn't exist.
145
-
// declarations[0]?.init?.arguments?.arguments[0]?.callee?.expressions; //work for jest test
143
+
//Mark's notes: so this was where the app was breaking. ES6 functions (e.g. const handleClick = () => {}) inside functional components were hitting this line and crashing when it tried to access arguments[0] and arguments didn't exist.
144
+
declarations[0]?.init?.arguments?.[0]?.callee?.expressions;//work for jest test;
146
145
147
-
// console.log('looked for expression, found:', expression);
148
-
if(expression===undefined)return;//Mark's Note: for a functional definition that isn't a hook, it won't have the callee being searched for above. This line will cause this forEach execution to stop here in this case.
146
+
console.log('looked for expression, found:',expression);
147
+
//Mark's Note: for a functional definition that isn't a hook, it won't have the callee being searched for above. This line will cause this forEach execution to stop here in this case.
148
+
if(expression===undefined)return;
149
149
letreactHook: string;
150
150
reactHook=expression[1].property?.name;
151
151
if(reactHook==='useState'){
152
152
// Obtain the variable being set:
153
+
//Mark's note: changed to point to second to last element of declarations because webpack adds an extra variable when converting files that use ES6, so the previous pointer wasn't working for this case
153
154
letvarName: string=
154
-
declarations[declarations.length-2]?.id?.name||// work react application; Mark's note: changed to point to second to last element of declarations because webpack added an extra variable and therefor declaration in the middle of the array cuz es6
155
+
declarations[declarations.length-2]?.id?.name||// work react application;
155
156
(Array.isArray(declarations[0]?.id?.elements)
156
157
? declarations[0]?.id?.elements[0]?.name
157
158
: undefined);//work for nextJS application
158
159
// Obtain the setState method:
160
+
//Mark's note: changed to point to last element of declarations because webpack adds an extra variable when converting files that use ES6, so the previous pointer wasn't working for this case
159
161
lethookName: string=
160
-
declarations[declarations.length-1]?.id?.name||// work react application; Mark's note: changed to point to last element of declarations because webpack added an extra variable and therefor declaration in the middle of the array cuz es6
162
+
declarations[declarations.length-1]?.id?.name||// work react application;
161
163
(Array.isArray(declarations[0]?.id?.elements)
162
164
? declarations[0]?.id?.elements[0]?.name
163
165
: undefined);//work for nextJS & Remix
164
166
// Push reactHook & varName to statements array
165
167
/**
166
-
* Mark's notes, it's interesting that they don't want to
167
-
* pass on reactHook 'useState'. I wonder why.
168
+
* Mark's notes, I'd like to alter the structure of the data
169
+
* to pass on the reactHook 'useState'. That way the user will
170
+
* eventually be able to view the difference between variables
0 commit comments