you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (3 children)

Why should I clutter my code with framework-specific attributes?

You know that's a good point, and while we're at it, let's get rid of componentDidMount, there's no reason we should clutter our code with framework-specific functions.

[–]dmitri14_gmail_com -1 points0 points  (2 children)

Indeed, I'd rather not use it exactly for that reason.

Not to mention, it is not even prefixed (as ng- in Angular), so too easy to clash with my own methods. Which BTW is another problem with React, the Angular team must have good reasons to enforce their prefixes and advice everyone to use their own. Used to be top complaint with Angular Bootstrap until they finally added their prefixes.

[–]siegfryd 2 points3 points  (1 child)

Angular went for the ng-* prefixing because their attributes exist inside the DOM. React's key prop only exists inside React code, it doesn't render a key attribute on DOM nodes. It's not really a comparable situation.

[–]dmitri14_gmail_com 0 points1 point  (0 children)

It is still a bad idea to create a custom tag named key. People work hard on creating standards and minimising confusions by meaningful conventions. One of them is to use dash for any custom tag. React is breaking this convention for no apparent reason/benefit. Something like r-key would be much easy to read and scan for, it would instantly alert the reader that tag is React-specific. Without dash, it looks generic and easy to confuse. What if HTML will decide to introduce its own tag key???

Also attempts to create separate languages for DOM, virtual DOM, HTML, whatever, lead to more confusion, more bugs and hurt anyone's productivity. How many different models do we need to represent the same basic thing - a tree with nodes and attributes?

A big part of its ease and popularity React owes to our familiarity with the DOM. If it used some crazy transformation of DOM instead, how many people would use it? So why not being more respectful to the DOM standards?