rsuite
Version:
A suite of react components
13 lines • 358 B
JavaScript
'use client';
/**
* Checks if a node is a leaf node.
* @param node The node to check.
* @param childrenKey The key of the children property.
*/
export function isLeafNode(node, childrenKey = 'children') {
if (!node) {
return true;
}
const children = node[childrenKey];
return !children || !Array.isArray(children) || children.length === 0;
}