Facebook has released the final version of React 15, which cleans up a lot of the DOM clutter, improves performance, and boosts SVG support.
Two major updates to the way React renders HTML is the removal of the data-reactid
attributes and the elimination of unnecessary <span>
elements on plain text. In prior versions, a rendered DOM element might look like this:
<div data-reactid=".0.0.5">
<div data-reactid=".0.0.5.0">Hello</div>
</div>
Now, the same HTML fragment would look like this:
<div>
<div>Hello</div>
</div>
The elimination of <span>
tags on certain plain text elements not only cleans up the rendered HTML, but also fixes issues developers may have experienced with unintended CSS behavior.
The new version also has complete support for all SVG attributes, but the way it was done was changed after the Release Candidate was out. In a GitHub commit message, Paul O’Shannessy said they updated their SVG whitelist after a discussion on making React easier for newcomers:
[The RC version] left us in an inconsistent state for our HTML and SVG behaviors. That's not awesome as there are already a number of things that must be learned for React and throwing in another inconsistency doesn't help. So we'll backpedal for now but still continue to provide full SVG support by going back to our previous whitelist and expanding it.
It's interesting to note that O'Shannessy wrote a script that scraped the Mozilla Developer Network in order to find a complete list of SVG attributes.
Because this is a major version release, there are breaking changes. In addition to some of the new DOM rendering changes, all of the deprecations introduced with version 0.14 are now removed.
Upon release of v15.0, those using version 1.8.9 of TypeScript could no longer compile TSX files due to a deprecation that was eliminated. While there was a workaround, Facebook reinstated the React.__spread
API and officially deprecated it. Dan Abramov warned that it will be gone in the next major release and any toolsets using it should stop. The TypeScript fix will be in the next release.
As InfoQ reported earlier, this is the first version of React to use the new numbering scheme. Previous versions were numbered like "0.14.7".
Based on new team meeting notes, the community should expect to see more minor and patch releases along with improved changelogs.