Skip to content

Continuous deconstruction problem about storeToRefs #2277

Closed Answered by posva
Z1oftheKill asked this question in Help and Questions
Discussion options

You must be logged in to vote

You are losing reactivity by destructuring a primitive from a reactive object (https://vuejs.org/guide/essentials/reactivity-fundamentals.html#reactive-proxy-vs-original-1)

Do

const {userInfo} = storeToRefs(...)
// or
const store = useStore()

And then consume it through the object:

<p>{{ userInfo.username }}</p>
<p>{{ store.userInfo.username }}</p>

I recommend you to give the whole page a read, it should help in understanding how the reactivity works and why that case breaks. That way you won't fall for it again in the future 😄

Replies: 2 comments 2 replies

Comment options

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

Comment options

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

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

This discussion was converted from issue #2275 on June 26, 2023 08:23.