Cannot use Pinia stores in Nuxt layers: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"? #3033
-
Reproductionhttps://github.com/okainov/pinia-nuxt-layers-bug-repro SummaryI'm observing the issue when stores are defined and working well in the base layer (as well as in
Steps to reproduce the bug0 .
When you try to open it, error message appears: [🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"? See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help. This will fail in production. Expected behaviorIt should work the same way as in the main layer Actual behaviorWhen you try to open it, error message appears: [🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"? See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help. This will fail in production. Additional informationI used |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
@posva could you please clarify why this is not an issue? Thanks! |
Beta Was this translation helpful? Give feedback.
-
While I played around with the reproducer for #3028, I was really surprised that it would work if I fix the imports thingy. So I digged deeper and seems like I found what was causing the issue Problematic code: import { defineStore } from 'pinia'
export const useTestStore = defineStore('test', () => { Working code: //import { defineStore } from 'pinia'
export const useTestStore = defineStore('test', () => { Yes, if I remove import @posva do you really think it's not a bug? Did I miss some documentation saying "do not use imports in layers" or something similar? |
Beta Was this translation helpful? Give feedback.
-
having the same issue, mentioned in the main discussion - hope we can get some good news |
Beta Was this translation helpful? Give feedback.
While I played around with the reproducer for #3028, I was really surprised that it would work if I fix the imports thingy. So I digged deeper and seems like I found what was causing the issue
Problematic code:
Working code:
Yes, if I remove import
defineStore
it starts working!@posva do you really think it's not a bug? Did I miss some documentation saying "do not use imports in layers" or something similar?