From b5f25d530f29a78472fedd3c9f8789192f89a773 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Mon, 22 Aug 2022 10:27:17 +0200 Subject: [PATCH] docs: naming convention in migration See #1578 --- packages/docs/cookbook/migration-vuex.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/docs/cookbook/migration-vuex.md b/packages/docs/cookbook/migration-vuex.md index d55d4909..31bb9eab 100644 --- a/packages/docs/cookbook/migration-vuex.md +++ b/packages/docs/cookbook/migration-vuex.md @@ -31,8 +31,8 @@ src └── stores ├── index.js # (Optional) Initializes Pinia, does not import stores ├── module1.js # 'module1' id - ├── nested-module2.js # 'nested/module2' id - ├── nested-module3.js # 'nested/module3' id + ├── nested-module2.js # 'nestedModule2' id + ├── nested-module3.js # 'nestedModule3' id └── nested.js # 'nested' id ``` @@ -118,7 +118,7 @@ interface State { userId: number | null } -export const useAuthUserStore = defineStore('auth/user', { +export const useAuthUserStore = defineStore('authUser', { // convert to a function state: (): State => ({ firstName: '', @@ -174,7 +174,7 @@ export const useAuthUserStore = defineStore('auth/user', { Let's break the above down into steps: -1. Add a required `id` for the store, you may wish to keep this the same as the namespace before +1. Add a required `id` for the store, you may wish to keep this the same as the namespace before. It is also recommended to make sure the `id` is in _camelCase_ as it makes it easier to use with `mapStores()`. 2. Convert `state` to a function if it was not one already 3. Convert `getters` 1. Remove any getters that return state under the same name (eg. `firstName: (state) => state.firstName`), these are not necessary as you can access any state directly from the store instance -- 2.47.3