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

Remove all redundant constructor definitions. #2

Closed
wants to merge 1 commit into from

Conversation

@tfrommen
Copy link
Contributor

@tfrommen tfrommen commented Jan 7, 2018

Hey Zac,

I took the liberty to remove all of your constructor definitions that didn't do anything else than passing on the ...arguments.

When using inheritance, it takes care that the respective class inherits all the methods from its parent, unless you define one of these methods on your own, of course.

So, there is no use in having code like this:

class Foo extends Bar {
    constructor() {
        super( ...arguments );
    }
}

as it is equivalent to just this:

class Foo extends Bar {}

Cheers,
Thorsten

@zgordon
Copy link
Owner

@zgordon zgordon commented Jan 13, 2018

Hmmm, okay cool! I thought for some reason this was necessary here but I think you're right :)

@tfrommen
Copy link
Contributor Author

@tfrommen tfrommen commented Jan 13, 2018

See React Base Fiddle as a working example. The Hello class doesn't have any constructor, and yet the name prop is passed no problem, and the output as expected.

@zgordon
Copy link
Owner

@zgordon zgordon commented Jan 13, 2018

Yup :)

I am going to hold off and merge this in a couple weeks when I release the next update.

I also want to add class properties in as well so going to rerecord all this and explain it.

Good tips though my friend :)

@tfrommen tfrommen closed this May 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.