Skip to content

Commit c2d9b1f

Browse files
Update README.md (#8)
1 parent c2034aa commit c2d9b1f

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ function App() {
4141

4242
return (
4343
<SortableTree
44-
items={treeStructure.items}
45-
onItemsChange={setTreeStructure}
44+
treeStructure={treeStructure}
45+
setTreeStructure={setTreeStructure}
4646
isCollapsible
4747
isRemovable
4848
allowNestedItemAddition
@@ -56,8 +56,8 @@ function App() {
5656

5757
| Prop | Type | Default | Description |
5858
| ------------------------- | --------------------------------------------------------------- | ----------- | -------------------------------------------------------------------------------------------------------------------- |
59-
| `items` | `TreeItems` | Required | The array of tree items to be rendered. |
60-
| `onItemsChange` | `React.Dispatch<React.SetStateAction<OptimizedTreeStructure>>` | Required | Callback function called when the tree structure changes. |
59+
| `treeStructure` | `OptimizedTreeStructure` | Required | The array of tree items to be rendered. |
60+
| `setTreeStructure` | `React.Dispatch<React.SetStateAction<OptimizedTreeStructure>>` | Required | Callback function called when the tree structure changes. |
6161
| `indentationWidth` | `number` | `undefined` | The indentation width for children elements. |
6262
| `isCollapsible` | `boolean` | `false` | Determines if tree items can be collapsed/expanded. |
6363
| `onLazyLoadChildren` | `(id: UniqueIdentifier, isExpanding: boolean) => Promise<void>` | `undefined` | Callback for lazy loading child items when a parent is expanded. Useful for getting child items from an API endpoint |
@@ -110,6 +110,15 @@ The `OptimizedTreeStructure` is used internally to improve performance for large
110110
function createOptimizedTreeStructure(items: TreeItems): OptimizedTreeStructure;
111111
```
112112

113+
### getItemById
114+
Retrieves a tree item by its unique identifier.
115+
```typescript
116+
function getItemById(
117+
structure: OptimizedTreeStructure,
118+
id: UniqueIdentifier,
119+
): TreeItem | undefined;
120+
```
121+
113122
### removeItemById
114123

115124
```typescript

0 commit comments

Comments
 (0)