Hacker News new | ask | show | jobs
by spankalee 2586 days ago
There are other ways to represent a UI as data that don't require a diff. JSX's default compiler output throws away information needed to do efficient updates, and instead requires diffing the entire old and new trees.

Immutable objects may optimize for checking for data changes, but only if you do that, as in shouldComponentUpdate or checking inside render(). They don't optimize the _diff_, which is done against the DOM.

1 comments

How often is diff done against the DOM? My understanding is that it’s done against last valid vDOM instead.
Sorry, you're correct for React, and for most VDOMs, though some do diff against the DOM.

The point is that the diff isn't sped up by using immutable data. The app data is only used to generate the vdom tree, and the diff is after that.