import { Menu as MuiMenu } from '@mui/material'; import { FC, useMemo } from 'react'; import MenuItem from './MenuItem'; const Menu: FC = (props) => { const { items = {}, muiMenuProps: menuProps, onItemClick, open, renderItem, } = props; const pairs = useMemo(() => Object.entries(items), [items]); const itemElements = useMemo( () => pairs.map(([key, value]) => ( onItemClick?.call(null, key, value, ...parent) } // The key is only relevant within the same branch; i.e., instance of // the same key under a different parent is OK. key={key} > {renderItem?.call(null, key, value)} )), [onItemClick, pairs, renderItem], ); return ( {itemElements} ); }; export default Menu as (props: MenuProps) => ReturnType>>;