News for hackers. Stuff that matters.
Re:An experienced Javascript developer’s account of learning... by epidemian on Saturday April 22, 2017 @05:42PM (#14174986)
> I don't think the `className` argument sticks. `class` is reserved so you can't use it.

But you can use it. JSX nodes get compiled into React.createElement calls with object literals[1], and {class: "foo"} is a perfectly valid object literal in JS, s there's nothing stopping `<div class="foo" />` to get compiled into `React.createElement("div", {class: "foo"})`

In fact, other frameworks that support JSX syntax allow the use of `class` instead of `className`[2], so it's not a limitation of JSX per-se, it's just a design decision on part of React (and an annoying one at that).

[1]: As noted in the first code snippet on the React homepage https://facebook.github.io/react/

[2]: E.g., Mithril https://mithril.js.org/jsx.html#jsx-vs-hyperscript

There are no comments on this comment yet.