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
This will likely never change as it is far too late but it bothers me so I want to at least mention it.
I think that using curlies "{}" for interpolation inside JSX is confusing, unintuitive and ugly. Typically curlies refer to an object or a block neither of which can actually exist inside the interpolation within JSX.
Parens "()" are typically used to enclose an expression which is exactly what is going on in JSX.
I propose that we switch from this:
<diva={{b: 1}}/>
Which is confusing for beginners because it looks like an object in an object, or if you are coming from mustache something different entirely.
To:
<diva=({b: 1})/>
Here it would be easy to explain that, like everywhere else in javascript, parans are used to represent an expression which in this case returns an object to the attribute of the virtual div.
@yiminghe my issue was never the simplicity in terms of compactness, but the simplicity in terms of explaining it to others.
Like I said, in javascript curly braces are used to denote blocks/scopes and objects. Anything that can be wrapped in parentheses in javascript must be an expression. In React the interpolation is always an expression so I think it would make sense to make the syntax look such that you were dealing with an expression.
This will likely never change as it is far too late but it bothers me so I want to at least mention it.
I think that using curlies "{}" for interpolation inside JSX is confusing, unintuitive and ugly. Typically curlies refer to an object or a block neither of which can actually exist inside the interpolation within JSX.
Parens "()" are typically used to enclose an expression which is exactly what is going on in JSX.
I propose that we switch from this:
Which is confusing for beginners because it looks like an object in an object, or if you are coming from mustache something different entirely.
To:
Here it would be easy to explain that, like everywhere else in javascript, parans are used to represent an expression which in this case returns an object to the attribute of the virtual div.
Just my thoughts, feel free to discuss or close.
This was originally posted here: https://phabricator.babeljs.io/T7074
The text was updated successfully, but these errors were encountered: