Skip to content

getActivePinia was called with no active Pinia when importing a store outside .vue files #2465

Closed Answered by posva
henrique-arthur asked this question in Help and Questions
Discussion options

You must be logged in to vote

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 runs useStore() so it doesn't detect the store.
Don't call useStore() directly in a ts file, call it in each component that needs it

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@henrique-arthur
Comment options

@posva
Comment options

posva Nov 1, 2023
Maintainer

@henrique-arthur
Comment options

Answer selected by henrique-arthur
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants