It's yet another "feature" to recognize unknown DOM attributes.
In the past, React used to ignore unknown DOM attributes. If you wrote JSX with an attribute that React doesn’t recognize, React would just skip it.
It has changed from React 16
and gives a warning. The way you use DOM components in React hasn’t changed, but now you have some new capabilities.
React has always provided a JavaScript-centric API to the DOM. Since React components often take both custom and DOM-related props, it makes sense for React to use the camelCase convention just like the DOM APIs
As for className
:
To specify a CSS class, use the className attribute. This applies to all regular DOM and SVG elements like <div>
, <a>
, and others.
If you use React with Web Components (which is uncommon), use the class attribute instead.
See Specifying Attributes with JSX:
Since JSX is closer to JavaScript than to HTML, React DOM uses camelCase property naming convention instead of HTML attribute names.
For example, class becomes className in JSX, and tabindex becomes tabIndex.