-
Notifications
You must be signed in to change notification settings - Fork 56
Add PropTypes and some fixs #22
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
Add PropTypes and some fixs #22
Conversation
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.
why attach everything to the class? what's the advantage over just using var outside of the constructor?
|
Basically see my first comment. I personally really don't like the notion of just dumping everything into the constructor, especially considering that that code is potentially gonna be run many more times than if it were outside of the constructor. Is there some important reason for doing this that I'm just missing here? Is this at least defined in some official style guide? |
|
Valid point. Sure, this can be improved. Ill work on it today.
|
Add PropTypes and some fixs
|
I think that everything that is used only by the object should be defined as properties of this object. Maybe we should define it like I did with propTypes property? Const before class, link as property after. On my side, I don't like when everything is declared as const outside of the object without being link with |
|
I kind of am on the fence on this as well. The implementation might change The problem is that ES6 does not allow static properties, thus forcing you I'd advocate that this.firstRoute should indeed be a class property, but Furthermore, regarding the order of things in a file, and assuming 1 class imports constants export class definition within the classes: constructor, and lifecycle methods from bootstrap to mixins A constant IMO should be something that can be seen on the same level as an On Tue, Feb 2, 2016 at 1:59 PM Nicolas Charpentier notifications@github.com
|
Ironically, you're actually exposing everything that the object is using to everyone with access to that class. Before, "private" variables were contained within the module scope. |
|
But yeah I actually don't care about the style question, it just felt kind of wasteful to put the style initialization into the constructor. |
|
@SEthX Go for that. @johannhof You're right about stylesheets, it should be a const before class definition. I didn't think about the style initialization each time the class is constructed. Thanks for this clarification.
I know that, but I think it's more cleaner to do that for specific properties to a class (As @SEthX said). I hope this proposal will emerge soon https://github.com/jeffmo/es-class-fields-and-static-properties. |
Related to #3.