From: Eduardo San Martin Morote Date: Mon, 24 Jun 2024 15:24:07 +0000 (+0200) Subject: docs: note about readonly X-Git-Tag: @pinia/nuxt@0.5.2~26 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2c01fc05b34bd5de74f1f7227b3157c4d93d5087;p=thirdparty%2Fvuejs%2Fpinia.git docs: note about readonly Close #vuejs/pinia#2701 --- diff --git a/packages/docs/cookbook/composables.md b/packages/docs/cookbook/composables.md index 1f65952f..307bb7e6 100644 --- a/packages/docs/cookbook/composables.md +++ b/packages/docs/cookbook/composables.md @@ -94,7 +94,7 @@ export const useAuthStore = defineStore('auth', { }) ``` -In [Setup Stores](#setup-stores), you need to use a helper named `skipHydrate()` on any state property that shouldn't be picked up from the initial state. Differently from option stores, setup stores cannot just _skip calling `state()`_, so we mark properties that cannot be hydrated with `skipHydrate()`. Note that this only applies to writable reactive properties: +In [Setup Stores](#setup-stores), you need to use a helper named `skipHydrate()` on any state property that shouldn't be picked up from the initial state. Differently from option stores, setup stores cannot just _skip calling `state()`_, so we mark properties that cannot be hydrated with `skipHydrate()`. Note that this only applies to state properties: ```ts import { defineStore, skipHydrate } from 'pinia' diff --git a/packages/docs/core-concepts/index.md b/packages/docs/core-concepts/index.md index 7ce1466a..2cc3474b 100644 --- a/packages/docs/core-concepts/index.md +++ b/packages/docs/core-concepts/index.md @@ -74,7 +74,7 @@ In _Setup Stores_: - `computed()`s become `getters` - `function()`s become `actions` -Note that you **must** return **all state properties** in setup stores for Pinia to pick them up as state. In other words, you cannot have _private_ state properties in stores. Not returning all state properties can break [SSR](../cookbook/composables.md), devtools, and other plugins. +Note that you **must** return **all state properties** in setup stores for Pinia to pick them up as state. In other words, you cannot have [_private_ state properties in stores](https://masteringpinia.com/blog/how-to-create-private-state-in-stores). Not returning all state properties or **making them readonly** will break [SSR](../cookbook/composables.md), devtools, and other plugins. Setup stores bring a lot more flexibility than [Option Stores](#option-stores) as you can create watchers within a store and freely use any [composable](https://vuejs.org/guide/reusability/composables.html#composables). However, keep in mind that using composables will get more complex when using SSR.