Skip to content

docs(watchers): clarify watchEffect re-evaluates dependencies on each run (closes #13688)#3420

Open
Dodothereal wants to merge 1 commit into
vuejs:mainfrom
Dodothereal:docs/watch-effect-conditional-deps
Open

docs(watchers): clarify watchEffect re-evaluates dependencies on each run (closes #13688)#3420
Dodothereal wants to merge 1 commit into
vuejs:mainfrom
Dodothereal:docs/watch-effect-conditional-deps

Conversation

@Dodothereal

Copy link
Copy Markdown

Summary

Add a short paragraph to guide/essentials/watchers.md clarifying that watchEffect re-evaluates its reactive dependencies on each synchronous run. This means refs reached only via conditional branches join the dependency set on the next tick, and refs that stop being read drop off cleanly — both behaviors are part of the intended design, not accidental side effects.

Closes #13688.

Why

Issue #13688 reports that the existing wording — "automatically tracks every reactive property accessed during its synchronous execution" — leaves readers unable to judge whether dependencies are recomputed per run (and therefore whether conditional access patterns add/remove deps dynamically) or frozen after the first run.

The proposed addition bridges that gap and reflects the actual runtime behavior of watchEffect. No source code changes — documentation only.

Test plan

  • Read vitepress dev locally to confirm the new paragraph renders inside the "watch vs. watchEffect" section of Essentials / Watchers.
  • Confirm the paragraph appears between the existing bullet list and the closing </div> for composition-api in src/guide/essentials/watchers.md.
  • Spot-check formatting (Oxford comma, no banned words like "easy" / "just" / "obviously").

AI assistance

This patch was drafted with the help of an AI coding assistant. The diff was reviewed line-by-line before submission and verified against the Vue docs writing guide (no emoji, plainer language, limited use of tip blocks).

… run

Add a short paragraph to guide/essentials/watchers.md after the
'watch vs. watchEffect' comparison explaining that deps are
re-evaluated on every synchronous run, so refs accessed inside
conditional branches join the dependency set on the next run (and
silently leave it when a control-flow change stops reading them).

Closes #13688
@netlify

netlify Bot commented Jun 26, 2026

Copy link
Copy Markdown

Deploy Preview for vuejs ready!

Name Link
🔨 Latest commit 843e32e
🔍 Latest deploy log https://app.netlify.com/projects/vuejs/deploys/6a3ef93b8a48ce0008b262ef
😎 Deploy Preview https://deploy-preview-3420--vuejs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant