3 ms·
> HTML(Div(Strong(text))) is terrible* > This is what JSX compiles to behind the scenes. Oh, it is much worse than that. By classic default it is: React.
by WorldMaker 3y ago
> HTML(Div(Strong(text))) is terrible*
> This is what JSX compiles to behind the scenes.
Oh, it is much worse than that. By classic default it is:
React.createElement('div', { /* props and attributes ... */ },
React.createElement('strong', { /* ... */ }, text))
Recent updates and other JSX frameworks simplified the name of `React.createElement` to just `jsx` or `h`. I've seen projects that manually write `h` calls like that everywhere, and it is indeed terrible.
(Source: I've just completed a bunch of crazy TSX work and got pretty familiar with the compiled forms.)
- wayfinder 3y agoYeah, you're right. I was kind of simplifying it. API-wise, it's more like document.createElement() but I didn't want to asterisk that because document.createElement() is actually a thing and I didn't want people to think it was a simple layer on top of document.createElement.