Skip to content

Conversation

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

2 participants