Pinia in an package: getActivePinia was called with no active Pinia. #1775
Unanswered
Reducetherisk
asked this question in
Help and Questions
Replies: 0 comments
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.
-
Hi,
I've been enjoying the power of Pinia stores in our Vue 3 application and would love to implement it into our component package.
It feels like I've tried a bunch of different solutions or ways to implement without much success.
The component package is build with Rollup and I've done the required
external: ['pinia']
andoutput.globals.pinia: 'pinia'
to exclude it from the build itself.The built output files end up with
import { defineStore } from 'pinia';
in them so I guess that is good, I'm not too familiar with the package/rollup stuff yet.So for the implementing application there is little difference between installing our package first or Pinia first.
Then in the plugin install function:
The stores are simply made like the docs suggest:
At this point I'm kind of lost as to what other options I can fallback on.
One way I've gotten it to work is whenever calling the
useDataTablesStore()
I call it with the Pinia instanceuseDataTablesStore(config.Pinia)
, also this is impossible when working with the mapping functions I think.However I don't think this is how it should work, I've seen people claim they can use it like it would be within an Vue3 application.
Would love some suggestions or possible fixes that people might have for me 🙏
Thank you for your time!
Beta Was this translation helpful? Give feedback.
All reactions