Skip to content

Commit

Permalink
add a warning against nesting shallow proxies inside deep ones
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 18, 2022
1 parent 16aebf6 commit 541bc7c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/api/reactivity-advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ Shallow version of [`reactive()`](./reactivity-core.html#reactive).

Unlike `reactive()`, there is no deep conversion: only root-level properties are reactive for a shallow reactive object. Property values are stored and exposed as-is - this also means properties with ref values will **not** be automatically unwrapped.

:::warning Use with Caution
Shallow data structures should only be used for root level state in a component. Avoid nesting it inside a deep reactive object as it creates a tree with inconsistent reactivity behavior which can be difficult to understand and debug.
:::

- **Example**

```js
Expand Down Expand Up @@ -177,6 +181,10 @@ Shallow version of [`readonly()`](./reactivity-core.html#readonly).

Unlike `readonly()`, there is no deep conversion: only root-level properties are made readonly. Property values are stored and exposed as-is - this also means properties with ref values will **not** be automatically unwrapped.

:::warning Use with Caution
Shallow data structures should only be used for root level state in a component. Avoid nesting it inside a deep reactive object as it creates a tree with inconsistent reactivity behavior which can be difficult to understand and debug.
:::

- **Example**

```js
Expand Down

0 comments on commit 541bc7c

Please sign in to comment.