Live data from Hacker News

What should go into JSX 2.0?

github.com

101–102 of 102 posts

Re: What should go into JSX 2.0?

#101
post #76
post #56

Earlier quoted context omitted.

I'd love for them to adopt something similar to Razor (Microsoft server side html engine) note: i've changed your example to show code inside html tags, i'm aware it does something different to yours. conditionals @if(cond1 && cond2) { foo } loops @for(var i in collection) { } variables @variable ternary/longer statement @(variable ? 1 : 2)

The one negative thing I've found with Razor is the ambiguous start and end of statements or expressions vs html. Sometimes a @ is required before a statement and sometimes its a syntax error, conversely statements and and expressions may be rendered as text if they follow html with a @. I think jsx's approach is clearer.

admittedly there is the occasional moment I hit where I need an extra @ or @: so it's not perfect, but I have much less issue reading that format than the { true && } syntax, also think @if is a lot nicer than .

Maybe just a personal thing.

Re: What should go into JSX 2.0?

#102
post #58

Earlier quoted context omitted.

JSX isn't templating. It's representing a virtual dom tree of function calls with a syntax more representative of the resulting markup.

You can build virtual dom trees or use real dom nodes using something like https://www.npmjs.com/package/morphdom . Tagged template strings let you build these features in without custom language extensions. See also: * https://www.npmjs.com/package/hyperx * https://www.npmjs.com/package/yo-yo

Right, but these just do what JSX does, but in runtime instead of at compile time.
Post reply on HN