Open
Description
We have accumulated a number of these nice-to-haves breaking changes that would be nice to incorporate. However, at this point JSX is a hugely adopted syntax in all kinds of tooling. Making breaking changes will churn that ecosystem significantly. I think it is probably only worth doing as a batch when the accumulated amount of changes makes it worth while.
Let's call it JSX 2.0.
What should go into it?
Since a completely incompatible version of JSX has landed in Reason it would be good to find a way to unify them.
I'd say at least we'd want:
- Document parsing of (X)HTML entities, or drop it even? #4 - Drop HTML encoding in text and attributes.
- AssignmentExpression in JSXAttributeName #21 - Computed attribute names.
- support object literal property value shorthand #23 - Object short hand notation.
- Allow template literal in JSXAttributeValue #25, JSX Compiler interpolation alternatives. #51, Support numeric attribute values #64 - Drop the need for curlies around attribute values if they're a single literal, or parenthesis.
Some more controversial/problematic ones that could plausibly be fixed:
- Proposal: implicitly use do-expression for any JSX expr container #39 - Implicit do expressions.
- Crazy Idea: Deprecate JSXText? #35 - Drop implicit text content and curlies as children.
- Custom attribute namespace #66 - Custom attribute namespaces.
What else?
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
syranide commentedon Oct 13, 2016
I would be interested in having a real story for comments e.g. #7.
{/**/}
feels like a hack, and kind of also is as it affects the children when used in certain places. If we actually end up going with #35 (bold, I like it :)) then just properly supporting regular comment syntax is a no-brainer IMHO.syranide commentedon Oct 13, 2016
Also, having an actual syntax for fragments would be a very welcome feature (e.g. the previously talked about
<>
).caub commentedon Oct 16, 2016
what would it be for fragments?
then it's the same, you'll need
{frag}
to insert it.I think arrays are good enough, similar to DOM fragments, and more powerful to manipulate
comments is a good idea,
<!-- -->
like html could be fine, but would they be inserted in the DOM (I guess no)? would it conflict with how react uses comments sometimes for text nodes I thinktheduke commentedon Oct 16, 2016
There should be a setting to turn it on for dev / off for production in the implementing libraries.
sbussard commentedon Oct 16, 2016
We need more restrictions on how JSX can be written. People are using terrible practices and teaching it to others. Example: child props should only be passed into components via childProps, otherwise it's a mess. There are so many ways to do things but few even ask if they should do it that way.
mohsen1 commentedon Oct 16, 2016
Something like Angular
ng-if
would be nice to have in JSX. Making rendering of an element conditional is not easy in JSX. Maybe adopt Angular 2*if
tachang commentedon Oct 16, 2016
Most of these changes wouldn't affect my codebase since I use them sparingly. Comments however would be great. It's kind of insane that normal javascript commenting isn't supported even with all the crazy tool chains we are running.
jasonslyvia commentedon Oct 16, 2016
I'd say allow adjacent elements without enclosing tag, really hate additional
<div>
s like this:syranide commentedon Oct 16, 2016
@jasonslyvia That's what fragments are for.
alistairhutton commentedon Oct 16, 2016
Would be nice to have something like how Adobe/Apache Flex deals with conditional inclusion of components. It is refered to as state in Flex world. You can assign a child component a state name and then when you set the parent components state it hides/shows child components as appropriate
oleksandr-shvets commentedon Oct 16, 2016
Hi guys! What do you think about this idea? https://github.com/alexander-shvets/cascading-component-layers-react
jasonslyvia commentedon Oct 16, 2016
@syranide It would be better if it could be solved in syntax level.
lacker commentedon Oct 16, 2016
BrendanFDMoore commentedon Oct 16, 2016
@mohsen1 our convention for our stateless functional components is to use:
which works pretty well for us. It's pretty clean as long as your outer component props are a clear pre-calculated boolean for show/hide. Because your components don't have any business logic, this should be fine already, right? ;)
edit: the ternary allows us to include an alternative, which we commonly do want, without needing to add an if
!someBoolFlag
check also.114 remaining items
adrians5j commentedon Nov 9, 2016
Can we add this ? Quick single line commenting :)
mvolkmann commentedon Nov 9, 2016
I imagine that would be hard because it is in the middle of XML-ish syntax.
I was hoping it could at least support XML-style comments since this feels
like XML.
On Wed, Nov 9, 2016 at 8:24 AM, Adrian notifications@github.com wrote:
R. Mark Volkmann
Object Computing, Inc.
jpeg729 commentedon Nov 19, 2016
@jamesseanwright while it is good to understand the reason why "className" is used, I do think that given that jsx is syntactically closer to html than jsx it would be more natural to use "class" rather than "className".
Let's keep "className", but let's add support for "class" too.
I would then have one less thing to do when I copy-paste static html produced elsewhere in order to transform it into jsx.
adrians5j commentedon Nov 23, 2016
@jpeg729 copy-pasting static html? You use http://magic.reactjs.net/htmltojsx.htm ? :)
jpeg729 commentedon Nov 23, 2016
@Adrian1358 sure I could use htmltojsx as you rightly point out, but it seems to me to be an intermediate step that could easily be avoided with a few small changes to jsx.
jokeyrhyme commentedon Nov 25, 2016
As an alternative to becoming more like HTML, what if JSX is more like JavaScript ?
For example, it would be nice if we could use template strings without the braces:
drcmda commentedon Dec 3, 2016
I wish JSX default args/spread could be extended to behave like a real object. The JSX parser could easily dump args into the _extends function.
Results in
Or optimized
gt3 commentedon Dec 13, 2016
Revisit: Choosing Type at Runtime
In JSX:
But instead:
With CSS in JSX gaining traction, perhaps it is time to revisit?
Concerns:
wqj97 commentedon Dec 16, 2016
What about annotation

neiker commentedon Dec 16, 2016
What about no
sebmarkbage commentedon Dec 16, 2016
I'm locking this conversation now. This thread is really too long to read so it's difficult for anyone new to get context on the previous suggestions so we end up repeating old points. Please search the issues or open another issue with new suggestions.