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
Invalid react/no-direct-mutation-state in constructor #1382
Comments
What error is thrown? |
Error thrown : |
This seems like a bug - although I can't conceive of why you'd want to create a component in the constructor like that. |
I agree with you, this code is not mine. It should be a closure problem to have access into the |
I know I am late to the party, but you have made a typo at the constructor of OneComponent class. Changing contructor to constructor removes the eslint warning. In your case eslint treats contructor as it would with any other method of OneComponent's class and it warns you that you should not mutate the state this way and use the setState method. |
In the following special case, the
react/no-direct-mutation-state
rule throw an invalid errorA better way is to not declare a component into another component constructor but that is an invalid linter error .
The text was updated successfully, but these errors were encountered: