Skip to content

Commit f956091

Browse files
docs: mention unwrapping of refs for readonly and shallow proxies (#840)
1 parent c7f5a9e commit f956091

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/api/basic-reactivity.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,19 @@ original.count++
7777
copy.count++ // warning!
7878
```
7979

80+
As with [`reactive`](#reactive), if any property uses a `ref` it will be automatically unwrapped when it is accessed via the proxy:
81+
82+
```js
83+
const raw = {
84+
count: ref(123)
85+
}
86+
87+
const copy = readonly(raw)
88+
89+
console.log(raw.count.value) // 123
90+
console.log(copy.count) // 123
91+
```
92+
8093
## `isProxy`
8194

8295
Checks if an object is a proxy created by [`reactive`](#reactive) or [`readonly`](#readonly).
@@ -191,6 +204,8 @@ isReactive(state.nested) // false
191204
state.nested.bar++ // non-reactive
192205
```
193206

207+
Unlike [`reactive`](#reactive), any property that uses a [`ref`](/api/refs-api.html#ref) will **not** be automatically unwrapped by the proxy.
208+
194209
## `shallowReadonly`
195210

196211
Creates a proxy that makes its own properties readonly, but does not perform deep readonly conversion of nested objects (exposes raw values).
@@ -209,3 +224,5 @@ state.foo++
209224
isReadonly(state.nested) // false
210225
state.nested.bar++ // works
211226
```
227+
228+
Unlike [`readonly`](#readonly), any property that uses a [`ref`](/api/refs-api.html#ref) will **not** be automatically unwrapped by the proxy.

0 commit comments

Comments
 (0)