docs(watchers): clarify watchEffect re-evaluates dependencies on each run (closes #13688)#3420
Open
Dodothereal wants to merge 1 commit into
Open
docs(watchers): clarify watchEffect re-evaluates dependencies on each run (closes #13688)#3420Dodothereal wants to merge 1 commit into
Dodothereal wants to merge 1 commit into
Conversation
… 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
✅ Deploy Preview for vuejs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a short paragraph to
guide/essentials/watchers.mdclarifying thatwatchEffectre-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
vitepress devlocally to confirm the new paragraph renders inside the "watch vs. watchEffect" section ofEssentials / Watchers.</div>forcomposition-apiinsrc/guide/essentials/watchers.md.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).