-
-
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
False positive on react/no-unused-prop-types
#1764
Comments
I think destructuring props off of this is pretty rare, but i agree it should work. |
In my case the code was better after the fix, but I agree it should work. |
Hello! Just showing my support for this bug to be fixed :-) 👍 |
Running into this all over our codebase. Here's a reduction of one of the cases, first the output, then the code:
code:
|
@matthargett The rule only considered this.state = computeStateFromProps({
maxItems: props.maxItems,
itemOpacityOutputRange: props.itemOpacityOutputRange,
...
}) |
Passing the props or state object around is a massive antipattern; always extract the props you need directly, and then pass them separately, or as a new object, to other functions. |
I came across some code looking like this where
myProp
was reportedly not being used, even though it was.It seems the double desctructure confused the rule because a change to the code below fixed it.
I think it may be similar to #933, except this one is not such an anti-pattern. It looks very strange on my reduced version, but in a context with more variables can be more natural.
The text was updated successfully, but these errors were encountered: