by hobofan · 9y ago · 0 comments
While it initially took some time to wrap my head around JSX (especially with a lot of JS mixed into it), after that I really started to enjoy JSX for its simplicity. The Fragment syntax adds some additional magic to JSX (which is rarely a good thing), and will also very likely break all the syntax highlighting out there again when used.
In: <></>
Out: <React.Fragment></React.Fragment>
WITCHCRAFT!! SORCERY!!
Teasing aside, I don't get what's magical about this. It's a straightforward transform. You can call that "magic," I'll call it "syntax."
Taking your example when putting it in front of someone seeing it for the first time:
In: <></>
Out (Newcomer): WTF does that mean? Did someone forget to put something in those tags?
I understand your point, but in practice people love tiny affordances like this, especially when they are needed as often as fragments are.
This is a balance, but it's important to consider the needs of power users too. Beginners don't stay beginners forever. We've thought about this for a few months, and decided that adding syntax would be better. I understand some people will always disagree though, and that's fine :-)
But for a newcomer to JSX it looks odd.
I'm probably just missing the reason for the syntax, we're already compiling - why can't fragments be added automatically as required?
https://news.ycombinator.com/item?id=15808311
If you have a specific proposal for how it should work, I'm happy to look at it and try to poke holes in it.