Skip to content

Commit 6569971

Browse files
authored
Merge pull request #261 from aspiers/hook-init
Deal gracefully with missing hook.init
2 parents 30cc177 + 59a7291 commit 6569971

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/backend/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export const getHooksNames = (elementType: string): Array<string> => {
114114
} else {
115115
// hook.init.object is '_useState2', '_useState4', etc.
116116
// eslint-disable-next-line no-lonely-if
117-
if (hook.init.object?.name) {
117+
if (hook?.init?.object?.name) {
118118
const varName: any = hook.init.object.name;
119119
if (!hooksNames[varName] && varName.match(/_use/)) {
120120
hooksNames[varName] = hook.id.name;

0 commit comments

Comments
 (0)