You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I see JSX as an essential part of React that makes it popular and loved.
I hope the JSX specification evolves over time. Even if is small minor syntax sugar improvements.
The text was updated successfully, but these errors were encountered:
When adding sugar for raw number isn't hard from parser perspective, support for omitting {} around AssignmentExpression adds ambiguity for parser.
Consider this <div onClick={ foo } />
The onClick attribute could be parsed as both ObjectLiteral with foo property shorthand and as AssignmentExpression of foo identifier.
The only way for omitting curly braces is to restrict possible expressions eliminating ambiguity.
Some features has been proposed before, but nothing seems to be happening even though they get upvoted.
Would it be easier if we think in terms of non-breaking changes to update the JSX specification?
E.g. I believe this is a non-breaking addition to the JSX specification.
<Foo bar=2 />
#64
In JSX 1.1 you would then have the options
<Foo bar=2 />
<Foo bar={2} />
JSX 1.0 (current version) you have the option
<Foo bar={2} />
Option 1:
<Foo bar=2 />
this could be evaluated to anAssignmentExpression
without the{ }
The generated AST should be identical for
<Foo bar=2 />
and<Foo bar={2} />
Option 2: We could extend allowed values for
JSXAttributeValue
https://facebook.github.io/jsx/
JSXAttributeValue :
"
'
{}
<
<
The definition of JSXNumber could be typeof
number
e.g.
2, 0x10, NaN
Could this be generalised?
Allow non-breaking changes where we omit the brackets for
JSXAttributeValue
?e.g.
Could also be
Languages evolves and gets updated.
I see JSX as an essential part of React that makes it popular and loved.
I hope the JSX specification evolves over time. Even if is small minor syntax sugar improvements.
The text was updated successfully, but these errors were encountered: