getActivePinia was called with no active Pinia when importing a store outside .vue files #2465
-
Beta Was this translation helpful? Give feedback.
Answered by
posva
Oct 29, 2023
Replies: 1 comment 3 replies
-
You need to take some measures when using the store outside of components (setup): https://pinia.vuejs.org/core-concepts/outside-component-usage.html#Using-a-store-outside-of-a-component. The problem you are seeing is that |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
henrique-arthur
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to take some measures when using the store outside of components (setup): https://pinia.vuejs.org/core-concepts/outside-component-usage.html#Using-a-store-outside-of-a-component.
The problem you are seeing is that
setActivePinia()
is being called after you import your ts file that runsuseStore()
so it doesn't detect the store.Don't call
useStore()
directly in a ts file, call it in each component that needs it