Skip to content

docs: add watchEffect notes #2596

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
docs: update watchEffect
  • Loading branch information
Alfred-Skyblue authored Dec 12, 2023
commit d5fc7f9c30f287bb11a4fc883e68c8f2c4dd4dc5
2 changes: 1 addition & 1 deletion src/api/reactivity-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ Takes an object (reactive or plain) or a [ref](#ref) and returns a readonly prox
Runs a function immediately while reactively tracking its dependencies and re-runs it whenever the dependencies are changed.

:::info Usage Note
`watchEffect` can only observe dependencies that are accessed during its initial execution. If you access reactive states within asynchronous operations, these states will not be collected as dependencies. Similarly, if you access these variables within an `if` statement and the condition is false during the initial execution, these variables will also not be collected as dependencies.
`watchEffect` will execute immediately upon initialization. During this initial execution, `watchEffect` will collect dependencies accessed during the first run. When the dependencies change, `watchEffect` will be re-executed. In subsequent executions, `watchEffect` will only collect dependencies accessed in the previous run, thus avoiding unnecessary executions and improving performance.
:::
- **Type**

Expand Down