| 763 | }) |
| 764 | |
| 765 | function 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 |