Skip to content

Commit

Permalink
docs(vue): add information about shallowRef for reactive data (#5706)
Browse files Browse the repository at this point in the history
  • Loading branch information
OlaAlsaker authored Aug 10, 2024
1 parent 5e7bb0c commit 58913b6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/framework/vue/guide/table-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,24 @@ dataRef.value = [
]
```

> ⚠️ `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.
```ts
const dataRef = ref([
{ id: 1, name: 'John' },
{ id: 2, name: 'Jane' }
])

// This will NOT update the table ❌
dataRef.value.push({ id: 4, name: 'John' })

// This will update the table ✅
dataRef.value = [
...dataRef.value,
{ id: 4, name: 'John' }
]
```

### Custom Initial State

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.
Expand Down

0 comments on commit 58913b6

Please sign in to comment.