Example with Object in store #440
-
Hello everyone, I am trying to use pinia, but I am having troubles with a composed getter. state: () => ({
data: {} as Record<string, unknown>,
selected: '',
snapshot: null
}) the action in B looks like this: actions: {
bind() {
const aStore = useAStore()
console.log(aStore.data) // <-- this is a proxy not the value
}
} With primitives and arrays it got the value, but with an object I got a proxy. Is this the intended behaviour? Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
I think I understand what you mean. The object being a proxy of the original object is expected, it's part of how Vue's reactive works. You should be able to use import {toRaw} from 'vue'
console.log(toRaw(store.data)) |
Beta Was this translation helpful? Give feedback.
-
How would you go about updating an Object property ? Thanks |
Beta Was this translation helpful? Give feedback.
What do you mean by it being a proxy instead of the value? Do you have a repro on codepen, jsfiddle or similar I can check?I think I understand what you mean. The object being a proxy of the original object is expected, it's part of how Vue's reactive works. You should be able to use
toRaw()
: