Skip to content

Commit 1078e85

Browse files
committed
remove 1 line return and check callee object for member expr
1 parent 45c064a commit 1078e85

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateSourceLocations.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,15 @@ function isManualMemoization(node: t.Node): boolean {
6868
if (t.isIdentifier(callee)) {
6969
return callee.name === 'useMemo' || callee.name === 'useCallback';
7070
}
71-
if (t.isMemberExpression(callee) && t.isIdentifier(callee.property)) {
71+
if (
72+
t.isMemberExpression(callee) &&
73+
t.isIdentifier(callee.property) &&
74+
t.isIdentifier(callee.object)
75+
) {
7276
return (
73-
callee.property.name === 'useMemo' ||
74-
callee.property.name === 'useCallback'
77+
callee.object.name === 'React' &&
78+
(callee.property.name === 'useMemo' ||
79+
callee.property.name === 'useCallback')
7580
);
7681
}
7782
}
@@ -150,7 +155,10 @@ export function validateSourceLocations(
150155

151156
// Use Babel's VISITOR_KEYS to traverse only actual node properties
152157
const keys = t.VISITOR_KEYS[node.type as keyof typeof t.VISITOR_KEYS];
153-
if (!keys) return;
158+
159+
if (!keys) {
160+
return;
161+
}
154162

155163
for (const key of keys) {
156164
const value = (node as any)[key];

0 commit comments

Comments
 (0)