import React, { useRef, useState } from 'react'; import { Button, ButtonGroup, Menu, MenuItem, Typography } from '@mui/material'; import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'; const SplitButton = ({ fullWidth, variant, color, disabled, onClick, options }) => { const anchorRef = useRef(); const [menuAnchorEl, setMenuAnchorEl] = useState(null); const [selected, setSelected] = useState(Object.keys(options)[0]); return ( <> setMenuAnchorEl(null)} anchorOrigin={{ vertical: 'bottom', horizontal: 'right', }} > {Object.entries(options).map(([key, value]) => ( { setSelected(key); setMenuAnchorEl(null); }} > {value} ))} ); }; export default SplitButton;