-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[Fix] react/jsx-no-bind
Add props to example
#1699
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
Conversation
docs/rules/jsx-no-bind.md
Outdated
@@ -121,8 +121,8 @@ Unfortunately [React ES6 classes](https://facebook.github.io/react/blog/2015/01/ | |||
|
|||
```jsx | |||
class Foo extends React.Component { | |||
constructor() { | |||
super(); | |||
constructor(props) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't actually needed, and to be fully correct, it'd be props, context
. It's a fine change tho.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While not strictly necessary it allows use of this.props
in the constructor and is suggested best practice by the React docs:
"Class components should always call the base constructor with props."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, what about constructor(...args) { super(...args);
? that way people copying the example will always forward all args.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments addressed @ljharb. Anything else or are you happy to merge?
…e in the constructor.
https://reactjs.org/blog/2015/01/27/react-v0.13.0-beta-1.html#autobinding