3 ms·
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,
by spankalee 7y 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.
- keymone 7y agoHow often is diff done against the DOM? My understanding is that it’s done against last valid vDOM instead.
- spankalee 7y agoSorry, 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.