From: Eduardo San Martin Morote Date: Mon, 8 Mar 2021 13:39:05 +0000 (+0100) Subject: refactor: set active pinia by default X-Git-Tag: v0.2.0~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=37e03884ed91c71dbcca0374fc98f027761bc3d4;p=thirdparty%2Fvuejs%2Fpinia.git refactor: set active pinia by default --- diff --git a/src/rootStore.ts b/src/rootStore.ts index 322146e9..eb73082b 100644 --- a/src/rootStore.ts +++ b/src/rootStore.ts @@ -84,9 +84,6 @@ export const PiniaPlugin: PluginFunction = function (_Vue) { const options = this.$options if (options.pinia) { options.pinia.Vue = _Vue - // this allows calling useStore() outside of a component setup after - // installing pinia's plugin - setActivePinia(options.pinia) // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L25 /* istanbul ignore else */ if (!(this as any)._provided) { @@ -136,6 +133,10 @@ export function createPinia(): Pinia { state, } + // this allows calling useStore() outside of a component setup after + // installing pinia's plugin + setActivePinia(pinia) + return pinia }