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

Function Menu

packages/react-aria/test/menu/useMenu.test.tsx:25–40  ·  view source on GitHub ↗
(props: AriaMenuProps<T> & {onSelect: () => void})

Source from the content-addressed store, hash-verified

23import userEvent from '@testing-library/user-event';
24
25function Menu<T extends object>(props: AriaMenuProps<T> & {onSelect: () => void}) {
26 // Create menu state based on the incoming props
27 let state = useTreeState(props);
28
29 // Get props for the menu element
30 let ref = React.useRef(null);
31 let {menuProps} = useMenu(props, state, ref);
32
33 return (
34 <ul {...menuProps} ref={ref}>
35 {[...state.collection].map(item => (
36 <MenuItem key={item.key} item={item} state={state} onAction={props.onSelect} />
37 ))}
38 </ul>
39 );
40}
41
42function MenuItem({item, state, onAction}) {
43 // Get props for the menu item element

Callers

nothing calls this directly

Calls 2

useTreeStateFunction · 0.90
useMenuFunction · 0.90

Tested by

no test coverage detected