getActivePinia was called with no active Pinia. Did you forget to install pinia? #1238
-
Reproductionhttps://stackblitz.com/edit/vitejs-vite-bmg8rr?file=src/forms/loginForm.js Steps to reproduce the bugIf you open the reproduction project on Stackblitz and then open the Console you will see this error:
Expected behaviorThe expected behavior is that there should not be an error. Actual behaviorThe error is shown. Additional informationSo I found this from Eduardo @posva where he described the problem in a different issue but it does not help with solving the issue. It is not clear how to fix this, what should I do instead?
The only workaround I could come up with was to wrap the call to my service (which uses a call to useAppStore) in a setTimeout - but this is not a good solution.
Now it works but ... 🤦🏻♂️ There has to be a better solution for this. |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 8 replies
-
You have three options:
|
Beta Was this translation helpful? Give feedback.
-
Hi, everyone after a lot of research I found the answer to this issue, `<script lang="ts" setup> const counterStore = useCounterStore(store()); |
Beta Was this translation helpful? Give feedback.
-
你好,我是林鸿斌。我已收到你的来信,谢谢你~保持开心~ 不用回复!
|
Beta Was this translation helpful? Give feedback.
-
Hi Guys, I created a tableau extension, in which I want to render a map component using pinia. This is how I try to load the app with map in the main.js file.main.jsimport { createApp } from 'vue'; const app = createApp(App); ===
|
Beta Was this translation helpful? Give feedback.
-
你好,我是林鸿斌。我已收到你的来信,谢谢你~保持开心~ 不用回复!
|
Beta Was this translation helpful? Give feedback.
-
if using this way, looks like computed will not execute when store value change |
Beta Was this translation helpful? Give feedback.
-
你好,我是林鸿斌。我已收到你的来信,谢谢你~保持开心~ 不用回复!
|
Beta Was this translation helpful? Give feedback.
You have three options:
useAuthStore()
function afterapp.use(pinia)
(https://pinia.vuejs.org/core-concepts/outside-component-usage.html#single-page-applications)useAuthStore(pinia)
.pinia
being the one created withconst pinia = createPinia()
setActivePinia(pinia)
somewhere beforeuseAuthStore()
(https://pinia.vuejs.org/ssr/#using-the-store-outside-of-setup)