Skip to content

Commit 115d6dc

Browse files
committed
update updated lifecycle hook description
1 parent 85329db commit 115d6dc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/v2/api/index.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,8 @@ type: api
447447

448448
<p class="tip">Note that __you should not use an arrow function to define a computed property__ (e.g. `aDouble: () => this.a * 2`). The reason is arrow functions bind the parent context, so `this` will not be the Vue instance as you expect and `this.a` will be undefined.</p>
449449

450-
Computed properties are cached, and only re-computed on reactive dependency changes. Note that if a certain dependency is out of the instance's scope (i.e. not reactive), the computed property will not be updated. In this situation, caching can be turned off by setting `cache: false`. However, since the dependency is still not reactive, modifying it will not trigger a DOM update.
451-
450+
Computed properties are cached, and only re-computed on reactive dependency changes. Note that if a certain dependency is out of the instance's scope (i.e. not reactive), the computed property will not be updated. In this situation, caching can be turned off by setting `cache: false`. However, since the dependency is still not reactive, modifying it will not trigger a DOM update.
451+
452452
In most situations, `cache: false` will not be an ideal solution. Whenever possible, it's much better to pull external data into the reactivity system. For example, if a computed property depends on the size of the window, you can store this information in `data`, then use the `resize` event to keep the value up-to-date. Now it's reactive!
453453

454454
- **Example:**
@@ -664,7 +664,7 @@ All lifecycle hooks automatically have their `this` context bound to the instanc
664664

665665
Called after a data change causes the virtual DOM to be re-rendered and patched.
666666

667-
The component's DOM will be in updated state when this hook is called, so you can perform DOM-dependent operations in this hook. However, in most cases you should avoid changing state in this hook, because it may lead to an infinite update loop.
667+
The component's DOM will have been updated when this hook is called, so you can perform DOM-dependent operations here. However, in most cases you should avoid changing state inside the hook. To react to state changes, it's usually better to use a [computed property](#computed) or [watcher](#watch) instead.
668668

669669
**This hook is not called during server-side rendering.**
670670

0 commit comments

Comments
 (0)