mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Dont compile functions w multiple args (infer mode)
This commit is contained in:
@@ -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():
|
||||
|
||||
+33
@@ -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],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
+10
@@ -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],
|
||||
};
|
||||
Reference in New Issue
Block a user