Continuous deconstruction problem about storeToRefs #2277
-
What problem is this solvingI defined a store:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
One more thing I want to make sure is that if you use storeToRefs you can't use the methods defined in actions? |
Beta Was this translation helpful? Give feedback.
-
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 😄 |
Beta Was this translation helpful? Give feedback.
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
And then consume it through the object:
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 😄