Skip to content

Commit

Permalink
Remove top-level requirement from react-transform
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewiggins committed Nov 15, 2023
1 parent 3ace88f commit 818ee98
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions packages/react-transform/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,12 @@ function isOptedOutOfSignalTracking(path: NodePath | null): boolean {
function isComponentFunction(path: NodePath<FunctionLike>): boolean {
return (
fnNameStartsWithCapital(path) && // Function name indicates it's a component
getData(path.scope, containsJSX) === true && // Function contains JSX
path.scope.parent === path.scope.getProgramParent() // Function is top-level
getData(path.scope, containsJSX) === true // Function contains JSX
);
}

function isCustomHook(path: NodePath<FunctionLike>): boolean {
return (
fnNameStartsWithUse(path) && // Function name indicates it's a hook
path.scope.parent === path.scope.getProgramParent()
); // Function is top-level
return fnNameStartsWithUse(path); // Function name indicates it's a hook
}

function shouldTransform(
Expand Down

0 comments on commit 818ee98

Please sign in to comment.