Skip to content

Commit 58913b6

Browse files
authored
docs(vue): add information about shallowRef for reactive data (#5706)
1 parent 5e7bb0c commit 58913b6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/framework/vue/guide/table-state.md

+18
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,24 @@ dataRef.value = [
5151
]
5252
```
5353

54+
> ⚠️ `shallowRef` is used under the hood for performance reasons, meaning that the data is not deeply reactive, only the `.value` is. To update the data you have to mutate the data directly.
55+
56+
```ts
57+
const dataRef = ref([
58+
{ id: 1, name: 'John' },
59+
{ id: 2, name: 'Jane' }
60+
])
61+
62+
// This will NOT update the table ❌
63+
dataRef.value.push({ id: 4, name: 'John' })
64+
65+
// This will update the table ✅
66+
dataRef.value = [
67+
...dataRef.value,
68+
{ id: 4, name: 'John' }
69+
]
70+
```
71+
5472
### Custom Initial State
5573

5674
If all you need to do for certain states is customize their initial default values, you still do not need to manage any of the state yourself. You can simply set values in the `initialState` option of the table instance.

0 commit comments

Comments
 (0)