Skip to content

Watch triggered even if value is not changed #2231

@edikdeisling

Description

@edikdeisling

Version

3.0.0

Reproduction link

https://jsfiddle.net/mravLjd6/4/

Steps to reproduce

Open console and watch output

What is expected?

Only one log message "true false"

What is actually happening?

Log fired every second with "false false"


const { computed, watch, ref } = Vue;

const source = ref(0);
const isZero = computed(() => source.value === 0);

watch(isZero, (prev, next) => console.log(prev, next)); // fires every second

setInterval(() => source.value++, 1000);

This is part from docs(https://v3.vuejs.org/guide/reactivity-computed-watchers.html#watch):

The watch API is the exact equivalent of the component watch property. watch requires watching a specific data source and applies side effects in a separate callback function. It also is lazy by default - i.e. the callback is only called when the watched source has changed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞 bugSomething isn't workinghas PRA pull request has already been submitted to solve the issuehas workaroundA workaround has been found to avoid the problem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions