Matt-Esch / virtual-dom

A Virtual DOM and diffing algorithm
MIT License
11.65k stars 780 forks source link

PureRenderMixin equivalent for virtual-dom #113

Closed staltz closed 9 years ago

staltz commented 9 years ago

PureRenderMixin in React can really help for boosting performance. It avoids diffing some parts of the virtual tree, saving computations. See this demo.

Also see this issue.

Because this is more related to mechanisms in React's components and not so much in the inner workings of their virtual DOM algorithms, it might not be easy to find an equivalent solution in virtual-dom. But maybe? Has this been tried?

One idea:

I have one back-of-the-envelope idea: to attach the parent data (React's "property") to the VTree, and inside virtual-dom's diff algorithm, it could use that data instead of the whole VTree structure, as a quick diff check prior to the real diff. Maybe we could even use a hash of the data instead of the data itself.

staltz commented 9 years ago

I saw Big list and modify sub tree and this advice:

use key on each element in this list, this will put virtual-dom in re ordering mode instead of diffing mode, this allows for very efficients moves of elements in the list.

Seems to be the same suggestion I gave above.

Raynos commented 9 years ago

This is already support first class as Thunks.

See https://github.com/Raynos/vdom-thunk

See https://github.com/Raynos/mercury/blob/master/docs/thunks.md