Skip to content

Commit

Permalink
doc: fix code example for editing a shared tree (#22427)
Browse files Browse the repository at this point in the history
this fixes a code example issue and adds a small clarification
  • Loading branch information
jenn-le authored Sep 6, 2024
1 parent 1a4b95f commit 02f8477
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions docs/content/docs/start/tree-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,13 @@ See [the API](../api/v2/tree/treechangeevents-interface) docs for more details.
## Editing Tree Data
There are built-in editing methods for each of the provided schema types.
For example, if your data is in an array, you can add an item like this:
For example, if your data is in an array, you can add a new todo item at index 3 like this:
```typescript
appData.root.items.insertAt(3);
appData.root.items.insertAt(3, new TodoItem({
description: "new item",
isComplete: false,
}),);
```
The schema types can also be edited using the assignment operator like this:
Expand Down

0 comments on commit 02f8477

Please sign in to comment.