Merge pull request #1898 from kevinweber/react/props--unnecessary-props

List bad example first to be consistent
This commit is contained in:
Jordan Harband
2018-08-26 22:21:05 -07:00
committed by GitHub

View File

@@ -440,17 +440,17 @@ This style guide is mostly based on the standards that are currently prevalent i
Filter out unnecessary props when possible. Also, use [prop-types-exact](https://www.npmjs.com/package/prop-types-exact) to help prevent bugs.
```jsx
// good
render() {
const { irrelevantProp, ...relevantProps } = this.props;
return <WrappedComponent {...relevantProps} />
}
// bad
render() {
const { irrelevantProp, ...relevantProps } = this.props;
return <WrappedComponent {...this.props} />
}
// good
render() {
const { irrelevantProp, ...relevantProps } = this.props;
return <WrappedComponent {...relevantProps} />
}
```
## Refs