File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -3,11 +3,9 @@ const jsx = require('acorn-jsx');
3
3
4
4
const JSXParser = acorn . Parser . extend ( jsx ( ) ) ;
5
5
6
- const hookState = { } ;
7
-
8
- module . exports = file => {
9
- // Initialize empty object to store the setters and getter
10
- let ast = JSXParser . parse ( file ) ;
6
+ // Helper function to recursively traverse AST of a specified component for all hook declarations
7
+ function getHookNames ( ast ) {
8
+ const hookState = { } ;
11
9
while ( Object . hasOwnProperty . call ( ast , 'body' ) ) {
12
10
// All module exports will always start off as a single 'FunctionDeclaration' type
13
11
// Traverse down .body once before invoking parsing logic and will loop through any .body after
@@ -35,6 +33,14 @@ module.exports = file => {
35
33
}
36
34
} ) ;
37
35
}
38
- // Return the object with setters and getters
39
36
return hookState ;
37
+ }
38
+
39
+ module . exports = file => {
40
+ // Initialize empty object to store the setters and getter
41
+ const ast = JSXParser . parse ( file ) ;
42
+ const hookNames = getHookNames ( ast ) ;
43
+
44
+ // Return the object with setters and getters
45
+ return hookNames ;
40
46
} ;
Original file line number Diff line number Diff line change @@ -147,5 +147,6 @@ module.exports = (snap, mode) => {
147
147
// const testFunction = consoleLoggerTest('Hello from reactime');
148
148
// return testFunction;
149
149
// }
150
+ return "This is reactime's return statement" ;
150
151
} ;
151
152
} ;
You can’t perform that action at this time.
0 commit comments