Skip to content

Conversation

GnsP
Copy link

@GnsP GnsP commented Sep 5, 2019

This RFC proposes a shorthand syntax for passing variables as props, where the variable
name is same as the prop name; similar to the shorthand properties in ES6
object literals.

For example : <Component prop1={prop1} prop2={prop2} /> can be written as <Component +prop1 +prop2 /> using the shorthand syntax.

This does not require changes to the codebase of React itself. It proposes extending the syntax and semantics of JSX, mainly in transpilers and existing tools

@milesj
Copy link

milesj commented Sep 5, 2019

JSX suggestions should be reported here: https://github.com/facebook/jsx/

@GnsP
Copy link
Author

GnsP commented Sep 5, 2019

JSX suggestions should be reported here: https://github.com/facebook/jsx/

@milesj could you please point me to the RFC / Suggestions process for facebook/jsx ? Should I create an Issue there or should I update the Syntax and AST specifications there and send a PR ?

@milesj
Copy link

milesj commented Sep 5, 2019

@GnsP Just create an issue there. You'll notice many suggestions already exist as issues there.

@GnsP
Copy link
Author

GnsP commented Sep 5, 2019

(y) Thanks

@ackvf
Copy link

ackvf commented Dec 30, 2019

@GnsP Can you post a link to your new suggestion?

Btw, I was also contemplating about this and I like this better <Component {prop1} {prop2} />

inspired by already working <Component {...{prop1}} />

@rafde
Copy link

rafde commented Mar 24, 2020

I stick with object spread

<Component {...{prop1, prop2}} />

It aligns with ReactJS being JS.

@gaearon
Copy link
Member

gaearon commented Aug 18, 2021

Closing since this is about JSX. We're not actively looking at changes to JSX but might at some point revisit all the proposals in this repo for a new revision so don't hesitate to discuss there.

@gaearon gaearon closed this Aug 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants