Skip to content
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

docs: add watchEffect notes #2596

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Alfred-Skyblue
Copy link
Member

@Alfred-Skyblue Alfred-Skyblue commented Dec 8, 2023

Description of Problem

I have observed that users often make some mistakes when using watchEffect, such as asynchronously accessing reactive variables, resulting in dependencies not being collected, or having an if statement with a false condition during the initial execution, leading to uncollected dependencies. These errors can cause watchEffect to malfunction. In this pull request, I have added some notes to help users avoid these mistakes.

relate: vuejs/core#9773 vuejs/core#9408 vuejs/core#2093

Proposed Solution

Additional Information

My English is not very good. You can correct my grammar or inaccurate wording at will. Thank you.

Copy link

netlify bot commented Dec 8, 2023

Deploy Preview for vuejs ready!

Name Link
🔨 Latest commit d5fc7f9
🔍 Latest deploy log https://app.netlify.com/sites/vuejs/deploys/65784d5ca334770008c89d1e
😎 Deploy Preview https://deploy-preview-2596--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 site configuration.

@fabruex
Copy link

fabruex commented Dec 12, 2023

Hi, I saw this pull request and I would add this point from last comment by LinusBorg in vuejs/core#9773, I think it's very important and clear:

reactive dependencies are re-collected on each run of an effect. This is so that a) new dependencies, that might not have been accessed/read from in a previous run, can be read, and b) old dependencies, that are no longer being read from in the latest run, can be discarded.

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.

2 participants