-
Notifications
You must be signed in to change notification settings - Fork 344
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
async watchEffect infinite loop with vue 2, fine with vue 3 #498
Comments
This also leads to an infinite loop. setup() {
const state = reactive({
data: null,
watchVar: 123,
});
const runFunction = (av) => {
console.log('var', av);
state.data = []; // <-- this line of code
}
watchEffect(() => {
console.log('watchEffect');
runFunction(state.watchVar);
})
}, |
Could this be elevated in priority? There are clear reproduction steps. Thanks! I've taken to doing this a lot, but it's certainly not ideal: // TODO convert to watchEffect
const func = () => {
// change state
}
watch(value, func);
func(); |
It's because of
That right there is a Vue getter being called for a mutation of the same property, which establishes a dependency on Looks like anything set on a |
Vue 3 example
Vue 2 example with composition-api
Uncommenting
data.loading = false;
causes infinite loop. I would expectdata.loading
to not be added to the tracked dependencies of the watch effect function.The text was updated successfully, but these errors were encountered: