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

Function Menu

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

Source from the content-addressed store, hash-verified

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