How to use the rc-tree/lib/util.getNodeChildren function in rc-tree

To help you get started, we’ve selected a few rc-tree examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ant-design / ant-design / components / tree / util.ts View on Github external
function traverseNodesKey(
  rootChildren: React.ReactNode | React.ReactNode[],
  callback: (key: string | number | null, node: AntTreeNode) => boolean,
) {
  const nodeList: React.ReactNode[] = getNodeChildren(rootChildren) || [];

  function processNode(node: React.ReactElement) {
    const {
      key,
      props: { children },
    } = node;
    if (callback(key, node as any) !== false) {
      traverseNodesKey(children, callback);
    }
  }

  nodeList.forEach(processNode);
}