Skip to content

Commit

Permalink
Merge pull request #2354 from golopot/patch-1
Browse files Browse the repository at this point in the history
[docs] remove outdated docs for `no-unused-prop-types`
  • Loading branch information
ljharb committed Jul 20, 2019
2 parents 49343d4 + f2891d9 commit fc70077
Showing 1 changed file with 0 additions and 48 deletions.
48 changes: 0 additions & 48 deletions docs/rules/no-unused-prop-types.md
Expand Up @@ -58,7 +58,6 @@ This rule can take one argument to ignore some specific props during validation.
## Known Issues/Limitations

- [False Positives: SFC (helper render methods)](#false-positives-sfc)
- [False Positives: Intermediate variables](#false-positives-intermediate-variables)

### False positives SFC
For components with Stateless Functional Components (often used as helper render methods);
Expand Down Expand Up @@ -109,50 +108,3 @@ AComponent.propTypes = {
bProp: PropTypes.string
};
```

### False positives intermediate variables
when assigning a part or a whole props object to a variable and using it to access a prop value.

```js
class AComponent extends React.Component {
render() {
const { props } = this;

return <div>{props.aProp}</div>;
}
}
AComponent.propTypes = {
aProp: PropTypes.string // aProp PropType is defined but prop is never used
};
```

suggested code structure to avoid the issue:

- accessing prop directly
```js
class AComponent extends React.Component {
render() {
return <div>{this.props.aProp}</div>;
}
}
AComponent.propTypes = {
aProp: PropTypes.string
};
```

- or assigning a final prop to a variable.

```js
class AComponent extends React.Component {
const { aProp } = this.props;
render() {
return <div>{aProp}</div>;
}
}
AComponent.propTypes = {
aProp: PropTypes.string
};
```

Using Intermediate variables might be desired and unavoidable for more complex props structure.
Like for shape prop types. To avoid false positive in this case make sure `skipShapeProps` is set to `true`.

0 comments on commit fc70077

Please sign in to comment.