3 ms·
JSX as a syntax itself doesn't require `className` and `htmlFor`, it can support `<div class="example"><label for="someInput">Hello World</label></div>` just fi
by WorldMaker 2y ago
JSX as a syntax itself doesn't require `className` and `htmlFor`, it can support `<div class="example"><label for="someInput">Hello World</label></div>` just fine syntactically, that React API choice is a leak from the standard DOM API which use `className` and `htmlFor` for historic reasons (of bad parsers and stricter keyword parsing in earlier JS standards). In theory by using the DOM names React has less work to do when diffing DOM elements (though how much React actually benefits from it today is an interesting discussion).
(Possibly relevant source/proof: my TSX-based library supports the HTML shortcut names just fine, like:
`class`: https://github.com/WorldMaker/butterfloat/blob/cb9498354a7fb5954993086877e5bb9cfe781811/static-dom.test.tsx#L23 https://github.com/WorldMaker/butterfloat/blob/cb9498354a7fb...
`for`: https://github.com/WorldMaker/butterfloat/blob/cb9498354a7fb5954993086877e5bb9cfe781811/static-dom.test.tsx#L59 https://github.com/WorldMaker/butterfloat/blob/cb9498354a7fb...)