Skip to content

Commit

Permalink
[docs] Clarify data-reactid in v15 post
Browse files Browse the repository at this point in the history
  • Loading branch information
zpao committed Apr 7, 2016
1 parent 3ed07ac commit 6fd2b29
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/_posts/2016-04-07-react-v15.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ If you can’t use `npm` yet, we provide pre-built browser builds for your conve

There were a number of large changes to our interactions with the DOM. One of the most noticeable changes is that we no longer set the `data-reactid` attribute for each DOM node. While this will make it more difficult to know if a website is using React, the advantage is that the DOM is much more lightweight. This change was made possible by us switching to use `document.createElement` on initial render. Previously we would generate a large string of HTML and then set `node.innerHTML`. At the time, this was decided to be faster than using `document.createElement` for the majority of cases and browsers that we supported. Browsers have continued to improve and so overwhelmingly this is no longer true. By using `createElement` we can make other parts of React faster. The ids were used to map back from events to the original React component, meaning we had to do a bunch of work on every event, even though we cached this data heavily. As we’ve all experienced, caching and in particularly invalidating caches, can be error prone and we saw many hard to reproduce issues over the years as a result. Now we can build up a direct mapping at render time since we already have a handle on the node.

**Note:** `data-reactid` is still present for server-rendered content, however it is much smaller than before and is simply an auto-incrementing counter.

<small>[@spicyj](https://github.com/spicyj) in [#5205](https://github.com/facebook/react/pull/5205)</small>

- #### No more extra `<span>`s
Expand Down

0 comments on commit 6fd2b29

Please sign in to comment.