From 4749d06b6026e46f9bf48791a49d20d3b27f80c3 Mon Sep 17 00:00:00 2001 From: JO <92811835+Jiamingou@users.noreply.github.com> Date: Thu, 2 Oct 2025 15:47:03 -0400 Subject: [PATCH 1/2] Update composing-stores.md According to "https://pinia.vuejs.org/core-concepts/#Setup-Stores", it claimed that "you must return all state properties in setup stores for Pinia to pick them up as state." Anyway, this code broke that rule , I believe is a typo, hence I "put" the `list` ref back into the user store. --- packages/docs/cookbook/composing-stores.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/docs/cookbook/composing-stores.md b/packages/docs/cookbook/composing-stores.md index 1463737d3c..1c414b3b3f 100644 --- a/packages/docs/cookbook/composing-stores.md +++ b/packages/docs/cookbook/composing-stores.md @@ -55,14 +55,13 @@ import { apiPurchase } from './api' export const useCartStore = defineStore('cart', () => { const user = useUserStore() - const list = ref([]) const summary = computed(() => { - return `Hi ${user.name}, you have ${list.value.length} items in your cart. It costs ${price.value}.` + return `Hi ${user.name}, you have ${user.list.length} items in your cart. It costs ${price.value}.` }) function purchase() { - return apiPurchase(user.id, list.value) + return apiPurchase(user.id, user.list) } return { summary, purchase } From cea0e8d27e337c6e87d5e77c2122a395b346f8cc Mon Sep 17 00:00:00 2001 From: JO <92811835+Jiamingou@users.noreply.github.com> Date: Fri, 3 Oct 2025 13:14:35 +0000 Subject: [PATCH 2/2] reverted all changes and return `list` instead. --- packages/docs/cookbook/composing-stores.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/docs/cookbook/composing-stores.md b/packages/docs/cookbook/composing-stores.md index 1c414b3b3f..c8fbfb84f9 100644 --- a/packages/docs/cookbook/composing-stores.md +++ b/packages/docs/cookbook/composing-stores.md @@ -55,16 +55,17 @@ import { apiPurchase } from './api' export const useCartStore = defineStore('cart', () => { const user = useUserStore() + const list = ref([]) const summary = computed(() => { - return `Hi ${user.name}, you have ${user.list.length} items in your cart. It costs ${price.value}.` + return `Hi ${user.name}, you have ${list.value.length} items in your cart. It costs ${price.value}.` }) function purchase() { - return apiPurchase(user.id, user.list) + return apiPurchase(user.id, list.value) } - return { summary, purchase } + return { list, summary, purchase } }) ```