I have a question regarding React and in particular JSX. Over the years I've noticed a recurring trend (way too often) where developers produce erroneous HTML. It leads to interactive, accessibility, and probably also SEO issues; people break W3C rules constantly. And well, they shouldn't.
JSX isn't HTML, and IDEs (as well as ESLint) don't validate JSX as HTML, not when I last checked anyway.
This will be considered perfectly fine pretty much everywhere.
Except it's a violation of the rules of HTML.
Many more issues like it (ul > div > li being one, and wrongly nesting block elements inside inline elements, etc.) take place and developers are none the wiser.
I'm an old guy (nearing my 40s) with 22+ years of experience, I grew up validating the hell out of my work and taking pride in it. To me, it's important; and to the internet, it should be important. The W3C rules are there for reasons; some more important than others.
TL;DR: My questions...
Is there anyone at the React or JSX team aware of this weakness and oversight?
Is this a validating concern (ESLint) or would TypeScript (I know, a different team) be the solution?
I can imagine the TypeScript wizards of the world could take the HTML specs and start going at it, making sure that inside an HTMLAnchorElement you cannot find nested any illegal elements.
Doable, probably. But that also sounds like a performance nightmare.
Personally, I live and breathe the W3C specs and won't make glaring mistakes as I described, but... I've reviewed probably more than a thousand job interview projects and portfolios where a shockingly large number of developers proudly present a webpage with 50 or more HTML spec errors.
Any insights are welcome. It looks like a daunting task, but--based on my anecdotal evidence--it would significantly increase the quality of React websites.
Because a button shouldn’t be inside an anchor element. It’s a bit paradoxical. Usually anchor elements are used for page navigations and links while buttons are for actions (usually) that don’t cause navigations (think of the like, follow, subscribe buttons for example). A button that may cause navigation that comes to mind are form submissions.
It's another anecdotal thing, but the same people who don't understand HTML also don't seem to work well with CSS, and many of them default to Tailwind, and many of those do the combination of React and Tailwind wrong.
React is too forgiving when it comes to writing bad HTML, and my question is mostly about whether it should be responsible for fixing it or not, and if yes: how.
15
u/[deleted] Mar 16 '23
I have a question regarding React and in particular JSX. Over the years I've noticed a recurring trend (way too often) where developers produce erroneous HTML. It leads to interactive, accessibility, and probably also SEO issues; people break W3C rules constantly. And well, they shouldn't.
JSX isn't HTML, and IDEs (as well as ESLint) don't validate JSX as HTML, not when I last checked anyway.
This will be considered perfectly fine pretty much everywhere.
Except it's a violation of the rules of HTML.
Many more issues like it (
ul > div > libeing one, and wrongly nesting block elements inside inline elements, etc.) take place and developers are none the wiser.I'm an old guy (nearing my 40s) with 22+ years of experience, I grew up validating the hell out of my work and taking pride in it. To me, it's important; and to the internet, it should be important. The W3C rules are there for reasons; some more important than others.
TL;DR: My questions...
Is there anyone at the React or JSX team aware of this weakness and oversight?
Is this a validating concern (ESLint) or would TypeScript (I know, a different team) be the solution?
I can imagine the TypeScript wizards of the world could take the HTML specs and start going at it, making sure that inside an
HTMLAnchorElementyou cannot find nested any illegal elements.Doable, probably. But that also sounds like a performance nightmare.
Personally, I live and breathe the W3C specs and won't make glaring mistakes as I described, but... I've reviewed probably more than a thousand job interview projects and portfolios where a shockingly large number of developers proudly present a webpage with 50 or more HTML spec errors.
Any insights are welcome. It looks like a daunting task, but--based on my anecdotal evidence--it would significantly increase the quality of React websites.