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

[feature proposal] JSX "Object Literal Property Value Shorthand" #52

Closed
tyler-dot-earth opened this issue Feb 13, 2016 · 2 comments
Closed

Comments

@tyler-dot-earth
Copy link

Common problem...

<SomeComponent propVariable={propVariable} />

I repeat "propVariable". I find myself doing this a lot... like, several times for one JSX object (usually a React component) is not uncommon.

Proposed solution...

<SomeComponent [propVariable] />

which would result to the same as the "common problem" example.

EDIT: Dan Abramov suggested this syntax instead:

<SomeComponent {propVariable} />

because "Using square brackets as in computed property name is confusing. In ES6 whatever’s inside brackets is a string name variable" and "[...] would have been more consistent [...]".

Inspired by:

@jkoudys
Copy link

jkoudys commented Feb 13, 2016

Easy enough to do already in ES6 already with a spread + implicit prop names. I don't think we need more syntax muddying the waters when this is already solved.

<SomeComponent {...{propVariable}} />

for the above, or multiple like so:

<AnotherComponent {...{foo, bar, baz}} />

@sebmarkbage
Copy link
Contributor

Duplicate of: #23

Also, see relevant discussion in: #37

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

No branches or pull requests

3 participants