-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Getting unrelated (react/no-this-in-sfc) violation error #1960
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
Component detection is probably recognizing it as an SFC since it returns null; this seems like a case where we should have less confidence because a) it's named not in PascalCase, b) it's a class field. cc @alexzherdev |
We're bitten again by the fact that |
@alexzherdev in this case it should be reporting a lower confidence than 1, because it's a class field, and because it's not named in PascalCase. |
Not sure if this is due to the same reason. Another sample causing unnecessary error: import React from 'react';
class Extended extends Base {
testA = () => {
this.abc(); // Error here - react/no-this-in-sfc
return (
<div>
Hello World
</div>
);
}
testB() {
this.abc(); // No error here
return (
<div>
Hello World
</div>
);
}
} It doesn't happen inside non-arrow functions |
I ran the following simple js program. But I got an error at line this.getA(); which is totally unrelated here. The error said "stateless functional components should not use this (react/no-this-in-sfc)"
What did you expect to happen?
No error expected
What actually happened? Please include the actual, raw output from ESLint.
Got this error - stateless functional components should not use this (react/no-this-in-sfc) for line
this.getA()
The text was updated successfully, but these errors were encountered: