4 ms·
className was named that to avoid conflict with the JS class syntax originally I believe, since JSX is inline - they probably could put in the work to change it
by Bahamut 10y ago
className was named that to avoid conflict with the JS class syntax originally I believe, since JSX is inline - they probably could put in the work to change it at this point, but it seems like a minimally beneficial change but massively disruptive at this point.
- jmtulloss 10y agoIt was named that to match the DOM api[0], which React does whenever possible. The DOM api is probably named for the reason you state. [0]: https://developer.mozilla.org/en-US/docs/Web/API/Element/className https://developer.mozilla.org/en-US/docs/Web/API/Element/cla...
- rmetzler 10y agoAnd the reason why the DOM API uses className is: class is a reserved keyword in JavaScript for a long time.
- lhorie 10y agoThere's also stuff like onClick, readOnly, xlinkHref... I would guess that a healthy number of React-related google searches are related to these gotchas