Earlier quoted context omitted.
I mostly agree with you but React isn’t just JavaScript. JSX is not JavaScript. It’s just that we’re so used to it we don’t consider it notable any more. Worth keeping in mind when you’re looking at a brand new framework.
I mean, you’re technically correct. But you’re also not understanding the point. What people mean when they say “React is just JavaScript” is… 1) JSX, more than any other templating system, is just HTML interleaved with JavaScript. It’s HTML, and anything between { and } is evaluated as JavaScript. 2) Inserting a React component’s “HTML tag” in your JSX is _actually_ the same as calling the JavaScript function. The H…
Marko – A declarative, HTML‑based language
101–110 of 189 posts
Re: Marko – A declarative, HTML‑based language
#102Earlier quoted context omitted.
I mostly agree with you but React isn’t just JavaScript. JSX is not JavaScript. It’s just that we’re so used to it we don’t consider it notable any more. Worth keeping in mind when you’re looking at a brand new framework.
I mean, you’re technically correct. But you’re also not understanding the point. What people mean when they say “React is just JavaScript” is… 1) JSX, more than any other templating system, is just HTML interleaved with JavaScript. It’s HTML, and anything between { and } is evaluated as JavaScript. 2) Inserting a React component’s “HTML tag” in your JSX is _actually_ the same as calling the JavaScript function. The H…
That’s not true though and IMO is one of the weaknesses of JSX: it looks like something it is not. Having to use className instead of class is one of the most obvious tells. But in theory if it was just HTML with {}s I should be able to do:
{stringContainingHTML}
and many other things you’re actually not able to do. Not to mention that things like onClick aren’t actually HTML attributes and are instead event listeners, etc etc.Once you grasp that what you’re actually doing is a function call with an object of arguments it makes sense. But it isn’t HTML. It’s a chain of function calls.
We’re all really used to it so we don’t think about it a lot. But I always try to remind myself of that when I look at a new unfamiliar syntax.
(not to mention, your example isn’t correct! don’t map to Component(), it maps to previouslyUnknownFunction(Component()), which is another confusing factor)
Re: Marko – A declarative, HTML‑based language
#103Earlier quoted context omitted.
Could you please try to be a bit more substantive with your comments? E.g., Why do you think JSX is the best? What limitations did you hit with those other template languages?
Most template languages can't do something like that: // data const numbered = true // or false const strings = ["a", "b", "c"] // render const items = strings.map(i => Item {i} ) if (numbered) return ( {items} ) else return ( {items} )
Re: Marko – A declarative, HTML‑based language
#104It looks interesting and in a past life I probably would have tried it out but do you know why I like React? Because it's just JavaScript. This ` ` and ` ` syntax is awful.
It started as a project at eBay and then got spun out to an open project around 2015
Re: Marko – A declarative, HTML‑based language
#105It looks interesting and in a past life I probably would have tried it out but do you know why I like React? Because it's just JavaScript. This ` ` and ` ` syntax is awful.
I mostly agree with you but React isn’t just JavaScript. JSX is not JavaScript. It’s just that we’re so used to it we don’t consider it notable any more. Worth keeping in mind when you’re looking at a brand new framework.
Re: Marko – A declarative, HTML‑based language
#106Re: Marko – A declarative, HTML‑based language
#107Re: Marko – A declarative, HTML‑based language
#108It looks interesting and in a past life I probably would have tried it out but do you know why I like React? Because it's just JavaScript. This ` ` and ` ` syntax is awful.
I mostly agree with you but React isn’t just JavaScript. JSX is not JavaScript. It’s just that we’re so used to it we don’t consider it notable any more. Worth keeping in mind when you’re looking at a brand new framework.
is just jsx(MyComponent, { prop: value })
Libraries and apps can use JSX or JS syntax.