Skip to content

when watch a reactive data, the old value is equal new value. if watch a ref, it's right. #1380

@huangfengya

Description

@huangfengya

Version

3.0.0-beta.15

Reproduction link

https://codesandbox.io/s/cool-lovelace-kw6hp?file=/src/App.vue

Steps to reproduce

import { reactive, watch } from 'vue'

export default {
mounted() {
},
setup() {
const msg1 = reactive({
val: 1
});
watch(msg1, (val, oldVal) => {
console.log(val === oldVal); // true?
console.log(new val: ${val.val}, old val: ${oldVal.val});
});
const changeMsg1 = () => {
msg1.val = 1;
};

    return {
        msg1,
        changeMsg1
    };
}

};

What is expected?

"val == oldVal" is false
"val.val === oldVal.val" is false

What is actually happening?

"val === oldVal" is true
"val.val === oldVal.val" is true


this app is use vue-cli3 create,then use "vue add vue-next" change version vue2 to vue3。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions