]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
refactor: set active pinia by default
authorEduardo San Martin Morote <posva13@gmail.com>
Mon, 8 Mar 2021 13:39:05 +0000 (14:39 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Mon, 8 Mar 2021 14:50:10 +0000 (15:50 +0100)
src/rootStore.ts

index 322146e96c91d522a1f926fd42afdd2c4e52d25f..eb73082b70ce0e8dff03b7a6e60c9500d6385729 100644 (file)
@@ -84,9 +84,6 @@ export const PiniaPlugin: PluginFunction<void> = 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
 }