Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/guide/essentials/watchers.md
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ unwatch()

Watchers declared synchronously inside `setup()` or `<script setup>` are bound to the owner component instance, and will be automatically stopped when the owner component is unmounted. In most cases, you don't need to worry about stopping the watcher yourself.

The key here is that the watcher must be created **synchronously**: if the watcher is created in an async callback, it won't be bound to the owner component and must be stopped manually to avoid memory leaks. Here's an example:
The key here is that the watcher must be created **synchronously**: it must be created during the synchronous execution of `setup()` or `<script setup>`. A watcher created in a callback that runs asynchronously, such as the callback passed to `setTimeout`, won't be bound to the owner component and must be stopped manually to avoid memory leaks. In `<script setup>`, a watcher can be created after a top-level `await` because the compiler restores the active component instance context. Here's an example:

```vue
<script setup>
Expand Down