]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
docs: use arrow function for state (#643)
authorTom Locke <tom@tomlocke.com>
Tue, 31 Aug 2021 09:21:52 +0000 (10:21 +0100)
committerGitHub <noreply@github.com>
Tue, 31 Aug 2021 09:21:52 +0000 (11:21 +0200)
packages/docs/core-concepts/state.md
packages/docs/introduction.md

index b16d5945df53063f01787526b1cc2d33be472712..2bf388c93c34be6f72de7532572927b0edf15d74 100644 (file)
@@ -6,8 +6,8 @@ The state is, most of the time, the central part of your store. People often sta
 import { defineStore } from 'pinia'
 
 const useStore = defineStore('storeId', {
-  // can also be defined with an arrow function if you prefer that syntax
-  state() {
+  // arrow function recommended for full type inference
+  state: () => {
     return {
       // all these properties will have their type inferred automatically
       counter: 0,
index 7dc00a6b6e562712d11f342983f7b00a549488aa..efc976ed0f80b5eb57e3f8d023bed459b1e72745 100644 (file)
@@ -26,7 +26,7 @@ This is what using pinia looks like in terms of API (make sure to check the [Get
 import { defineStore } from 'pinia'
 
 export const useCounterStore = defineStore('counter', {
-  state() {
+  state: () => {
     return { count: 0 }
   },
   // could also be defined as