]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
fix: correct store in getters vue 2
authorEduardo San Martin Morote <posva13@gmail.com>
Wed, 8 Sep 2021 14:42:14 +0000 (16:42 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Wed, 8 Sep 2021 14:42:14 +0000 (16:42 +0200)
packages/pinia/src/store.ts

index 690bad224d14f10ed76e4b927a34721c05f168b5..e695d85e70ca2c99785db7d6fca01412e5d18810 100644 (file)
@@ -127,10 +127,12 @@ function createOptionsStore<
         computedGetters[name] = markRaw(
           computed(() => {
             setActivePinia(pinia)
-            // const context = store || ref(localState).value
+            // it was created just before
+            const store = pinia._s.get(id)!
             // @ts-expect-error
             // return getters![name].call(context, context)
-            return store && getters![name].call(store, store)
+            // TODO: avoid reading the getter while assigning with a global variable
+            return getters![name].call(store, store)
           })
         )
         return computedGetters