-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: react/no-object-type-as-default-prop
is disabled when using a ref
prop
#3767
Comments
That's because forwardRef's callback is not a component. Function components take |
Actually, the issue does not come from the From what I can see, this behavior is caused by this line in the rule's implementation: having more than one argument in the function will not execute the rule. Second test: const ErrorIsShown = ({ foo = {} }) => null;
const ErrorIsAbsent = forwardRef(function({ foo = {} }, ref) {
return null
}); |
I see what you mean. Given that it's fine to have |
That is exactly it. |
That’d be great, thanks! |
Is there an existing issue for this?
Description Overview
Brief description
The
react/no-object-type-as-default-prop
does not run when a component has aref
prop as a second argument.Show example of your code (as text format), add images/videos/gifs to help explain example
Both of these components should error because an object type is used as a default prop.
However, the second component (with a ref) does not error.
Link to repro: https://github.com/JulienR1/eslint-react-no-object-type-as-default-prop-repro
What command(s) did you run to reproduce issue?
Expected Behavior
Brief description
Components with
ref
props should also generate errors when using default object type props.eslint-plugin-react version
v7.34.2
eslint version
v8.57.0
node version
v20.12.2
The text was updated successfully, but these errors were encountered: