Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Here in the intro it doesn't even explain that you need to use className instead of class.

Again, because `className` is not React specific, it's JS DOM API specific. Sounds like the real problem is that people start learning React without fully learning the JS DOM API itself, then they get confused when things like `className` or `htmlFor` show up.

> Yes, className is a property of the Element interface but it is not the attribute used when writing HTML. You're still changing how you write HTML.

You're not writing HTML. That's the entire gist of the parent comment. It looks like HTML only insofar as HTML is a type of XML. But what you're really doing underneath is something like:

    const el = document.getElementById('item');
    el.className = el.className === 'active' ? 'inactive' : 'active';
JSX is simply syntactic sugar on top of DOM operations like that (albeit within the context of a renderer like React; Svelte eschews a renderer entirely and truly is creating DOM operations like above). In React, JSX would be direct syntactic sugar for:

    React.createElement('div', null, `Hello ${this.props.toWhat}`);
> It is no longer standard

It is standard, it is in the Element API, I don't know how it can get more standard than that. Again, it sounds like the problem is that people really should learn JS and DOM separately before ever touching React. Sadly, too many beginners in web dev and programming in general gravitate towards a React/Node stack, which are good production tools, but they really ought to know how we got there.

Now why I don't use DSLs is because they don't use the standard of the JS DOM API, they use their entirely new creation, like v-for or #if :else. That is why I consider Vue or Svelte templates to be DSLs while not JSX, because the latter is fully compliant with the Element spec, and it uses plain JS/TS, unless you define a DSL to be so broad as to be literally any transformation of code, which, well, I can't practically agree with.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: