]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
docs: Use `state` instead of `this` in example (#1295)
authorJohannes Cleve <36301325+JohannesCleve@users.noreply.github.com>
Sun, 15 May 2022 09:20:34 +0000 (11:20 +0200)
committerGitHub <noreply@github.com>
Sun, 15 May 2022 09:20:34 +0000 (11:20 +0200)
Using `state` is the preferred way to access data in a getter. So it's better to use it correctly in examples.

packages/docs/core-concepts/getters.md

index c940f5f63a83c84ed08ece3d6086415a800aa39c..2c0e601623f04615ed22393b1c9c4d681f9e0696 100644 (file)
@@ -184,8 +184,8 @@ const useCounterStore = defineStore('counterStore', {
     counter: 0
   }),
   getters: {
-    doubleCounter() {
-      return this.counter * 2
+    doubleCounter(state) {
+      return state.counter * 2
     }
   }
 })