-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
watchEffect is called twice on initialisation #2125
Labels
🐞 bug
Something isn't working
Comments
Related to this: 5f40539 watchEffect(() => {
// track
price.value
// trigger
price.value = 20
}); watch(price, () => {
// trigger
price.value = 20
}, { immediate: true }) // immediate |
As a supplement to what @HcySunYang pointed out, calling some methods can both trigger and track in one effect, which can lead to an infinite recursion in some scenarios. e.g. const a = reactive([])
const b = ref(0)
const c = ref(0)
watchEffect(() => {
if (b < 10)
a.push(1)
})
watchEffect(() => {
if (c > -10)
a.push(1)
}) |
Oh, it was fixed while I was typing 😁 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Version
3.0.0-rc.11
Reproduction link
https://jsfiddle.net/qrh0ubaj/
Steps to reproduce
Consider this component
What is expected?
In rc.10, it only displays one change when initialised (
Price changed to 10
)What is actually happening?
In rc.11, it displays this change twice.
The text was updated successfully, but these errors were encountered: