-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1438 from jseminck/no-unsed-state-docs
Add docs for no-unused-state
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Prevent definitions of unused state (react/no-unused-state) | ||
|
||
Warns you if you have defined a property on the state, but it is not being used anywhere. | ||
|
||
## Rule Details | ||
|
||
The following patterns are considered warnings: | ||
|
||
```jsx | ||
class MyComponent extends React.Component { | ||
state = { foo: 0 }; | ||
render() { | ||
return <SomeComponent />; | ||
} | ||
} | ||
|
||
var UnusedGetInitialStateTest = createReactClass({ | ||
getInitialState: function() { | ||
return { foo: 0 }; | ||
}, | ||
render: function() { | ||
return <SomeComponent />; | ||
} | ||
}) | ||
``` | ||
|
||
The following patterns are not considered warnings: | ||
|
||
```jsx | ||
class MyComponent extends React.Component { | ||
state = { foo: 0 }; | ||
render() { | ||
return <SomeComponent foo={this.state.foo} />; | ||
} | ||
} | ||
|
||
var UnusedGetInitialStateTest = createReactClass({ | ||
getInitialState: function() { | ||
return { foo: 0 }; | ||
}, | ||
render: function() { | ||
return <SomeComponent foo={this.state.foo} />; | ||
} | ||
}) | ||
``` |