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
no-unused-state doesn't respect usage in gDSFP #2061
Comments
What React version have you set in |
16.3.1 |
I believe this was fixed in #1829 (it's not released yet). |
That’s probably ok since it can be polyfilled in older react versions. |
I see that this issue is still open, although ostensibly it was fixed and released already in 7.12.0 at the end of December. I am running into basically the same problem today with 7.14.3, but the difference is that I'm using TypeScript. When I copy/paste the JS code from above, it works fine (no warning). But when I write a very similar TSX file, I still get a warning import { Component } from 'react';
interface Props {}
interface State {
flag: boolean;
}
class RuleTest extends Component<Props, State> {
readonly state: State = {
flag: false, // <-- warning shows up on this line
};
static getDerivedStateFromProps = (props: Props, state: State) => {
const newState: Partial<State> = {};
if (!state.flag) {
newState.flag = true;
}
return newState;
};
}
export default RuleTest; I am somewhat ignorant of how these rules are implemented, so I apologize if this is expected behavior. Also, if I should create a new issue from this, please let me know. (For now I will likely just disable the rule in my project.) |
cc @alexzherdev ^ |
It's only fixable for the modern TS eslint parser; the old one fails to provide the information required. |
The text was updated successfully, but these errors were encountered: