Getter does not work in Setup Store #1496
-
Reproductionhttps://github.com/yxyx-github/pinia-getter-issue Steps to reproduce the bugCreate a store with Pinia and define a getter which returns any value. Use the Setup Store. In the reproduction repository the store is located at Expected behaviorRegardless of whether I use the Option Store or the Setup Store, I should have access to my getter in any Vue-Component. Actual behaviorWhen I use the Option Store, my getter works fine. On the other hand, when I use the Setup Store, my getter returns undefined. I do not get any other error messages. Additional informationNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You have to return the value: export const useStore = defineStore('default', () => {
const sampleArg = ref('hello world')
const demoGetter = computed(() => sampleArg)
+ return { sampleArg, demoGetter }
}) |
Beta Was this translation helpful? Give feedback.
You have to return the value:
export const useStore = defineStore('default', () => { const sampleArg = ref('hello world') const demoGetter = computed(() => sampleArg) + return { sampleArg, demoGetter } })