'What is `react/no-unused-state` and why is it bad?
Can someone explain exactly what no-unused-state
means and why is it considered bad practice?
I can't seem to find any information other than the following sentence taken from the commit:
This adds a new rule, react/no-unused-state, which discovers state fields in a React component and warns if any of them are never read.
Solution 1:[1]
The eslint-plugin-react docs give some examples for what's considered good and bad code.
If you keep state in your component which is not used, you include code in your application that fulfills no purpose.
That in turn brings a whole bunch of issues, including that you ship code which is effectively never tested, that you have to maintain code which brings no benefit etc.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |