Skip to content
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

[Fix] react/jsx-no-bind Add props to example #1699

Merged
merged 1 commit into from Mar 9, 2018

Conversation

ronanmathew
Copy link
Contributor

@@ -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) {
Copy link
Member

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.

Copy link
Contributor Author

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."

Copy link
Member

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.

Copy link
Contributor Author

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?

@ljharb ljharb merged commit 58956ea into jsx-eslint:master Mar 9, 2018
@ronanmathew ronanmathew deleted the patch-1 branch March 10, 2018 00:12
This was referenced Sep 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants