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

Watch not detect change when ref is changed inside this watch #1727

Closed
edikdeisling opened this issue Jul 28, 2020 · 2 comments
Closed

Watch not detect change when ref is changed inside this watch #1727

edikdeisling opened this issue Jul 28, 2020 · 2 comments

Comments

@edikdeisling
Copy link

Version

3.0.0-rc.4

Reproduction link

https://jsfiddle.net/zs3td94f/

Steps to reproduce

  1. Open jsfiddle
  2. Click button multiple times
  3. Watch console output

What is expected?

Every click fire console output

What is actually happening?

Only one log. Watch not detect change which made inside watch callback


This behaviour appeared in version 3.0.0-beta.23
There are link to the same example with 22 version
https://jsfiddle.net/hg64rkdx/3/

In the version 22 watch fires twice per click

@posva
Copy link
Member

posva commented Jul 28, 2020

You can pass the { flush: 'sync' } option to recreate that behavior you want. This comment #1706 (comment) should be relevant to you

@edikdeisling
Copy link
Author

Thank you for response. Yeah, sync will be working.
But nevertheless, I can understand why there is no 2 logs per click, but it is weird that watch do not work at all after ref is changed. It means that it is forbidden to change watched ref in watch callback?

If it is expected behaviour, feel free to close the issue.

yyx990803 added a commit that referenced this issue Jul 30, 2020
…iggering

fix #1740

Previous fix for #1727 caused `watchEffect` to also recursively trigger
itself on reactive array mutations which implicitly registers array
`.length` as dependencies and mutates it at the same time.

This fix limits recursive trigger behavior to only `watch()` callbacks
since code inside the callback do not register dependencies and
mutations are always explicitly intended.
@github-actions github-actions bot locked and limited conversation to collaborators Nov 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants