Using stores inside different store actions and passing Pinia instance on SSR #2457
Unanswered
niksy
asked this question in
Help and Questions
Replies: 1 comment
-
|
I'm curious if something like this would work: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Let’s say I have following application code:
Component
app.vuelooks like this:Store
./page-store.jslooks like this:And explanation on some core parts is as following:
fetchDatais called on SSR to fetch initial data, and on each route change when that component gets activatedfetchDatasince it’s just static method without any knowledge of Vue instanceawaitcalls to prevent losing Pinia instance contextMy question is do we also need to pass Pinia instance to
useMainStorecall insideusePageStoreaction when running inside SSR, or is that considered under definition "inside component" and it’s not necessary inside that context?Is Pinia already implicitly available for every page store instantiation if Pinia instance was passed before when instantiating parent store? I know that should work for non-SSR (client) context, but I’m not sure for SSR context.
For example, in the code example for shared actions call to
useUserStoredoesn’t have Pinia instance as argument, and the documentation mentions SSR apps, so my understanding is that it isn’t necessary to pass Pinia instance to any external store calls inside actions if it was already passed down to parent store which has that action defined.Beta Was this translation helpful? Give feedback.
All reactions