Skip to content

Why destructure a reactive obj also causing shallow reactive property unwraping #12282

Discussion options

You must be logged in to vote

This is called ref unwrapping an explained in the docs

https://vuejs.org/api/reactivity-core.html#reactive

Ref unwrapping:

const count = ref(1)
const obj = reactive({ count })

// ref will be unwrapped
console.log(obj.count === count.value) // true

// it will update `obj.count`
count.value++
console.log(count.value) // 2
console.log(obj.count) // 2

// it will also update `count` ref
obj.count++
console.log(obj.count) // 3
console.log(count.value) // 3

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@FoundTheWOUT
Comment options

Comment options

You must be logged in to vote
1 reply
@FoundTheWOUT
Comment options

Answer selected by FoundTheWOUT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #12281 on October 28, 2024 08:35.