Skip to content

Conversation

@majapw
Copy link
Contributor

@majapw majapw commented Oct 21, 2015

When there are static variables like propTypes and defaultProps, we shouldn't export them until we have actually set them onto the Component. This may change if the current ES7 proposal for static class properties gets accepts, and we update to support it.

When there are static variables like `propTypes` and `defaultProps`, we shouldn't export them until we have actually set them onto the `Component`. This may change if the current ES7 proposal for static class properties gets accepts, and we update to support it.
@ljharb
Copy link
Collaborator

ljharb commented Oct 21, 2015

LTGM 👍

The important thing in my eyes is that we don't have things like:

const foo = someExpression;
export default foo;

… in these cases we should just have

export default someExpression

@justjake
Copy link
Collaborator

If we want to make this change, we should add a lint rule for it. Personally, I prefer doing export default class Foo extends Component { ... } and then adding the propTypes attribute afterwards. Does the spec specify that objects are frozen when they are exported?

@ljharb
Copy link
Collaborator

ljharb commented Oct 21, 2015

No, nothing in JS is frozen unless you Object.freeze it.

imo there shouldn't be any expressions after the default export. I'm fine with the way this style is currently described, but I think that this change makes sense.

@justjake
Copy link
Collaborator

why? seems overly perscriptive

@majapw
Copy link
Contributor Author

majapw commented Oct 21, 2015

Logically, it looks better? I feel like you shouldn't be able to add things to a module after it's been exported. It feels weird?

@justjake
Copy link
Collaborator

doesn't feel weird to me, coming from Python, Ruby and Go.

@hshoff
Copy link
Member

hshoff commented Nov 4, 2015

Let's merge it for now and if things get weird we can always reopen follow up with another PR. Thanks @majapw!

hshoff added a commit that referenced this pull request Nov 4, 2015
`export default` should not be inline with the class declaration
@hshoff hshoff merged commit 8514f74 into airbnb:master Nov 4, 2015
@philihp
Copy link

philihp commented Nov 10, 2015

Modifying properties after you've done an export default feels like requesting the bartender for another drink after you've already settled up your tab.

@ljharb
Copy link
Collaborator

ljharb commented Nov 10, 2015

@philihp wait, you don't do that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants