Skip to content

Commit 7324490

Browse files
committed
docs: add setup store persisted state (returned refs only)
1 parent 155511e commit 7324490

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/guide/limitations.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,16 @@ To get around this you can:
5555
- Use the [`afterHydrate`](/guide/config#afterhydrate) hook to recreate the objects after rehydration.
5656
- Use a custom [`serializer`](/guide/config#serializer) that supports the data types you want to persist.
5757
:::
58+
59+
## Only returned `ref()`s are persisted with setup stores
60+
61+
When using the setup store syntax (composition), only `ref()`s that returned can be persisted. Additionally, `computed()`s cannot be persisted whether or not they are returned.
62+
63+
This is due to how Pinia creates store from the setup declaration:
64+
65+
> - `ref()`s become `state` properties
66+
> - `computed()`s becore `getters`
67+
68+
> Note that you **must** return **all state properties** in setup stores for Pinia to pick them up as state.
69+
70+
You can find more information in the [Pinia documentation](https://pinia.vuejs.org/core-concepts/#Setup-Stores).

0 commit comments

Comments
 (0)