Tree
/ API ReferenceTree
/ API ReferencegetParent
Gets the parent node of a node by its id.
The Gist
import { getParent } from '@weser/tree'
const node = getParent(tree, 'node-id')
Parameters
| Parameter | Type | Description |
|---|---|---|
| rootNode | T | The root node of the tree. |
| id | string | The id of the node whose parent node will be returned. |
Returns
(T | null) The parent node of the node with the given id or null if no node with the given id was found.
© 2024-present Robin Weser. All Rights Reserved.