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
Copy file name to clipboardExpand all lines: src/backend/controllers/statePropExtractors.ts
+5-7Lines changed: 5 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -83,9 +83,7 @@ export function getHooksStateAndUpdateMethod(
83
83
84
84
// ---------------------GET STATE VAR NAME & HOOK NAME--------------------------
85
85
/**
86
-
* This function receive a string representation of a functional component.
87
-
* This function then uses JSX parser to traverse through the function string,
88
-
* and extract the state variable name and its corresponding setState method.
86
+
* This function receive a string representation of a functional component. This function then use JSX parser to traverse through the function string, and extract the state variable name and its corresponding setState method.
89
87
* @param elementType - The string representation of a functional component
90
88
* @returns - An array of objects with key: hookName (the name of setState method) | value: varName (the state variable name)
// Points 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
128
125
letvarName: string=
126
+
// Points to second to last element of declarations because webpack adds an extra variable when converting files that use ES6
129
127
declarations[declarations.length-2]?.id?.name||// work react application;
130
128
(Array.isArray(declarations[0]?.id?.elements)
131
129
? declarations[0]?.id?.elements[0]?.name
132
130
: undefined);//work for nextJS application
133
131
// Obtain the setState method:
134
-
// Points 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
135
132
lethookName: string=
133
+
//Points to last element of declarations because webpack adds an extra variable when converting files that use ES6
136
134
declarations[declarations.length-1]?.id?.name||// work react application;
0 commit comments