4 ms·
I wish this was out many years ago. Would have saved me a lot of time trying to understand what the new syntax was and why it was in syntactically valid. It s
by nashashmi 3y ago
I wish this was out many years ago. Would have saved me a lot of time trying to understand what the new syntax was and why it was in syntactically valid.
It still doesn’t go over why the greater than and less than signs somehow still transform into a syntactically valid JS especially when none of the jsx is in quotes.
- kazinator 3y agoThe new syntax isn't syntactically valid Javascript. It's valid syntax inside a transpiler language like Babel. It doesn't have to be in quotes because the tool, like Babel, has tokenization and parsing rules for it which disambiguate it somehow. It basically is a kind of quote. Or, well quasiquote. Just like " introduces a textual quote, a token sequence like <div> introduces a HTML quasiquote. You can transform a language into JS that doesn't look like JS in any regard. So of course you can transform one that looks like JS, but does weird things that would be syntax errors in JS.