Hacker News new | ask | show | jobs
by codethief 870 days ago
The translation from JSX to JS is rather easy, though. It is just syntactic sugar.
2 comments

You still need a full JS(x) parser (and lexer) though since / symbols are contextual (as are < in JSX).

/ and < in operator positions becomes operators, whilst / in plain JS in a value position becomes the start of an reg-exp and < becomes the start of an JSX tag, so to handle it there needs to be a full parser (with a pull-lexer to correctly handle the contextual part) as you cannot just do a textual replacement due to ambiguity.

The class vs className breaks every css style.
It is a macro ("syntactic sugar") for JavaScript, not HTML.