MCPcopy Create free account
hub / github.com/adobe/react-spectrum / Tree

Function Tree

packages/react-stately/stories/tree/useTreeState.stories.tsx:53–74  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

51}
52
53function Tree(props) {
54 let state = useTreeState(props);
55 let ref = useRef(null);
56
57 let keyboardDelegate = useMemo(
58 () => new TreeKeyboardDelegate(state.collection, state.disabledKeys),
59 [state.collection, state.disabledKeys]
60 );
61
62 let {collectionProps} = useSelectableCollection({
63 keyboardDelegate,
64 ref,
65 selectionManager: state.selectionManager
66 });
67
68 return (
69 <div {...collectionProps} ref={ref} role="tree">
70 {/* oxlint-disable-next-line react/react-compiler */}
71 {TreeNodes({nodes: state.collection, state})}
72 </div>
73 );
74}
75
76function TreeNodes({nodes, state}: {nodes: Collection<Node<any>>; state: any}) {
77 return Array.from(nodes).map(node => <TreeItem node={node} key={node.key} state={state} />);

Callers

nothing calls this directly

Calls 3

useTreeStateFunction · 0.90
useSelectableCollectionFunction · 0.90
TreeNodesFunction · 0.85

Tested by

no test coverage detected