Add vnode caching warning under hyperscript documentation

This commit is contained in:
Barney Carroll 2016-11-27 15:16:55 +00:00
parent b399af1073
commit 2e43bf4f7b

View file

@ -408,3 +408,9 @@ var BetterListComponent = {
}
}
```
#### Avoid creating vnodes outside views
When a redraw encounters a vnode which is strictly equal to the one in the previous render, it will be skipped and its contents will not be updated. While this may seem like an opportunity for performance optimisation, it should be avoided because it prevents dynamic changes in that node's tree - this leads to side-effects such as downstream lifecycle methods failing to trigger on redraw. In this sense, Mithril vnodes are immutable: new vnodes are compared to old ones; mutations to vnodes are not persisted.
The component documentation contains [more detail and an example of this anti-pattern](components.md#avoid-creating-component-instances-outside-views).