MCPcopy Index your code
hub / github.com/primer/react / useSubTree

Function useSubTree

packages/react/src/TreeView/TreeView.tsx:765–781  ·  view source on GitHub ↗
(children: React.ReactNode)

Source from the content-addressed store, hash-verified

763})
764
765function useSubTree(children: React.ReactNode) {
766 return React.useMemo(() => {
767 const subTree = React.Children.toArray(children).find(
768 child => React.isValidElement(child) && child.type === SubTree,
769 )
770
771 const childrenWithoutSubTree = React.Children.toArray(children).filter(
772 child => !(React.isValidElement(child) && child.type === SubTree),
773 )
774
775 return {
776 subTree,
777 childrenWithoutSubTree,
778 hasSubTree: Boolean(subTree),
779 }
780 }, [children])
781}
782
783// ----------------------------------------------------------------------------
784// TreeView.LeadingVisual and TreeView.TrailingVisual

Callers 1

TreeView.tsxFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected