Add vnode caching warning under hyperscript documentation
This commit is contained in:
parent
b399af1073
commit
2e43bf4f7b
1 changed files with 6 additions and 0 deletions
|
|
@ -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).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue