Skip to content

Commit ba4416f

Browse files
docs: Recursive Store - edit pass (#783)
1 parent e829e5f commit ba4416f

File tree

1 file changed

+10
-5
lines changed
  • packages/docs/src/pages/tutorial/store/recursive

1 file changed

+10
-5
lines changed

packages/docs/src/pages/tutorial/store/recursive/index.mdx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@ title: Recursive Store
33
layout: tutorial
44
---
55

6-
In this example, we have created a store that contains other objects rather than just primitives. (`store.counter` is object literal.)
6+
This example features a store that contains other objects rather than just primitives. The `store.counter` property is an object literal.
77

8-
The example does not work, because by default the `useStore` only sets up watches on top-level properties. To make the example work, we need to either:
9-
1. wrap the `{count:0}` in another `useStore()` call, which is cumbersome OR
10-
2. ask the `useStore` to apply reactivity to all properties recursively by passing the additional argument `{recursive:true}`.
8+
The example doesn't work as is, because by default the `useStore` function only watches top-level properties.
119

10+
To make the example work, you need to do one of two things:
1211

13-
Notice that it is perfectly OK (and encouraged) to pass the stores to other components. (Stores are not tied to any one component.)
12+
1. Wrap `{count:0}` in another `useStore()` call (which is a bit cumbersome)
13+
14+
1. Allow `useStore` to recursively apply reactivity to all properties by passing the additional argument: `{recursive:true}`.
15+
16+
> **Your task:** Update the sample with the `useStore()` function.
17+
18+
Note that stores are not tied to any single component. In fact, you can pass stores from one component to another.

0 commit comments

Comments
 (0)