Tree
/ API Reference
Tree
/ API Reference

getParent

Gets the parent node of a node by its id.

The Gist

import { getParent } from '@weser/tree'

const node = getParent(tree, 'node-id')

Parameters

ParameterTypeDescription
rootNodeTThe root node of the tree.
idstringThe 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.

On this page