Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak docs with warning to fix #2508 #2895

Merged
merged 2 commits into from
Jun 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/vnodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ When creating libraries that emit vnodes, you should use this module instead of

### Avoid anti-patterns

#### Avoid memoizing mutable vnodes
#### Avoid reusing vnodes

Vnodes are supposed to represent the state of the DOM at a certain point in time. Mithril.js' rendering engine assumes a reused vnode is unchanged, so modifying a vnode that was used in a previous render will result in undefined behavior.
Vnodes are supposed to represent the state of the DOM at a certain point in time. Mithril.js's rendering engine assumes a reused vnode is unchanged, so modifying a vnode that was used in a previous render will result in undefined behavior.

It is possible to reuse vnodes to prevent a diff, but it's preferable to use the `onbeforeupdate` hook to make your intent clear to other developers (or your future self).
It is possible to reuse vnodes in place to prevent a diff, but it's preferable to use the [`onbeforeupdate`](lifecycle.md#onbeforeupdate).

#### Avoid passing model data directly to components via attributes

Expand Down
Loading