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

Proposal: <Component { prop: value } /> syntax #71

Open
rchanou opened this issue Feb 12, 2017 · 1 comment
Open

Proposal: <Component { prop: value } /> syntax #71

rchanou opened this issue Feb 12, 2017 · 1 comment

Comments

@rchanou
Copy link

rchanou commented Feb 12, 2017

A slightly different take on this request.

Allow curly braces without a preceding prop= to define props. This makes it easy to refactor JSX props into objects by removing the need to change prop=value to prop: value, for each prop.

This is currently a syntax error, so allowing this shouldn't break existing code.

Example:

<Component
  {
    bool: true,
    expr: x + y,
    ...spreadObject
  }
/>

It also has nice symmetry with current spread syntax:

const props = {
  bool: true,
  expr: x + y,
  ...spreadObject
}

// This is already valid JSX
<Component
  {
    ...props
  }
/>
@rchanou
Copy link
Author

rchanou commented Feb 12, 2017

Guess there's already been a lively discussion about this in #23, but I think this is worth being its own issue.

@rchanou rchanou closed this as completed Mar 2, 2017
@rchanou rchanou reopened this Mar 2, 2017
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

1 participant