-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
no-unused-prop-types rule does not recognise component that returns an array #1682
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
Comments
Our component detection likely requires a component to return JSX. It becomes very very difficult to detect if an SFC that returns no JSX is in fact a component. A temporary workaround should be to add a comment above the SFC that says |
This similarly applies to this rule as well https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md |
Note that you can also return a React.Fragment or |
That could work as a wrapper 👍 |
Forgot about this, but re-reading, why do you need to detect that the function is a component? If the prop is unused in the function body then the rule should error, it shouldn't matter if it returns JSX or not. |
@leonaves if it's not a component, then it doesn't have "props" - it has arguments, and it can't have propTypes. |
Example:
React 16 allows for arrays to be returned from components, but in the above example, the
no-unused-prop-types
seems to not recognise thatcustomClass
is unused. It does detect it when the component is changed to:The text was updated successfully, but these errors were encountered: