-
-
Notifications
You must be signed in to change notification settings - Fork 258
Conversation
I’m not sure why {
"type": "CommentBlock",
"value": " this is a comment ",
"start": 4,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 27
}
}
} I’m pretty sure it has to do with the Any ideas? |
We'll have to hold off on this until it's been specced and added to the facebook/jsx#57 repo. TypeScript and Flow also support JSX so there's value in having this specced there so they can come into compliance as we add support. |
I don't think either TypeScript or Flow support non-React variants of JSX atm so it probably doesn't matter but we can add it. We also don't support namespaces which is speced. |
@kittens: The language extension this PR implements was just added to the JSX specification (facebook/jsx#59). What’s remaining to get this PR merged, and can you comment on the failing test? See my comment above for more details on from the reasons I found that might make it fail. |
Just curious @kittens, what’s the status on this? |
this.next(); | ||
node.expression = this.parseExpression(); | ||
this.expect(tt.braceR); | ||
children.push(this.finishNode(node, "JSXSpreadChild")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSXSpreadChild
would need to be added to babel-types as well and also to babel-generator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! We can follow up in the Babel PR. |
This PR comes from a conversation in facebook/jsx#57 where I recommended adding the ability to spread children. For the full rationale see that issue, here’s an abridged version:
JSX with React allows us to do this:
Which translates to this:
That doesn’t make sense and it has disadvantages for simpler JSX consumers as well as type systems. Instead JSX should allow us to do this:
Which would translate to this:
This PR aims to extend JSX by allowing the spreading of children like so:
As another note, it seems like React itself will consider this an anti-pattern. However as JSX is an open standard used by more than just React we should consider the entire ecosystem when considering the merits of this extension. Let’s keep discussion of whether or not the extension should be added to JSX in facebook/jsx#57 and let’s talk about technical implementations here.
In facebook/jsx#57 the language extension got a +1 from @syranide (facebook/jsx#57 (comment)) and @sebmarkbage (facebook/jsx#57 (comment)).