News for hackers. Stuff that matters.
Re:React 16 by scottfr on Tuesday September 26, 2017 @03:51PM (#15341969)
This is interesting

> Instead of ignoring unrecognized HTML and SVG attributes, React will now pass them through to the DOM.

Does that mean we can start using "class" instead of "className"?

Re:React 16 by syntor on Tuesday September 26, 2017 @03:55PM (#15342001)
I always assumed `class` was a keyword, which is why then went with `className` instead.
Re:React 16 by sorahn on Tuesday September 26, 2017 @04:59PM (#15342460)
Re:React 16 by danabramov on Tuesday September 26, 2017 @06:15PM (#15343031)
Yes, the reason is that you can't write something like

    const { class } = props
Which is very common and deeply confusing.

So even though "class" will technically work now, it will still warn, and ask that you use "className".

(And officially supporting both would make it confusing for third party components since each would have to also support both.)

Re:React 16 by iBelieve on Tuesday September 26, 2017 @03:59PM (#15342033)
I think you can (with a warning), but it's still recommended to use the normal React naming conventions according to [0]:

> Note: always use the canonical React naming for all supported attributes.

Looking through the examples, it looks like non-string class values will be converted to strings, while non-string className values will be ignored (with a warning).

[0] https://facebook.github.io/react/blog/2017/09/08/dom-attribu...