Dont compile functions w multiple args (infer mode)

This commit is contained in:
Joe Savona
2023-09-14 16:22:06 -07:00
parent ca1217be6d
commit 14630c0618
3 changed files with 51 additions and 2 deletions
@@ -480,8 +480,14 @@ function isReactFunctionLike(
functionName !== null &&
(isComponentName(functionName) || isHook(functionName))
) {
// As an added check we also look for hook invocations or JSX
return callsHooksOrCreatesJsx(node);
return (
// As an added check we also look for hook invocations or JSX
callsHooksOrCreatesJsx(node) &&
// and avoid helper functions that take more than one argument
// helpers are _usually_ named with lowercase, but some code may
// violate this rule
node.get("params").length <= 1
);
}
// Otherwise for function or arrow function expressions, check if they
// appear as the argument to React.forwardRef() or React.memo():
@@ -0,0 +1,33 @@
## Input
```javascript
// @compilationMode(infer)
// Takes multiple parameters - not a component!
function Component(foo, bar) {
return <div />;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [null, null],
};
```
## Code
```javascript
// @compilationMode(infer)
// Takes multiple parameters - not a component!
function Component(foo, bar) {
return <div />;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [null, null],
};
```
@@ -0,0 +1,10 @@
// @compilationMode(infer)
// Takes multiple parameters - not a component!
function Component(foo, bar) {
return <div />;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [null, null],
};