import React, { useState } from 'react'; import classnames from 'classnames'; import PropTypes from 'prop-types'; const ListMenu = ({ options = [], renderer, onClick }) => { const [selectedIndex, setSelectedIndex] = useState(null); const ListItem = (props) => { const flex = 'flex flex-row justify-between items-center'; const theme = 'bg-indigo-dark'; const hover = 'hover:bg-primary-dark'; const spacing = 'p-3 h-8'; return (
{renderer && renderer(props)}
); }; return (
{options.map((option, index) => { const onClickHandler = () => { setSelectedIndex(index); onClick({ ...option, index }); }; return ( ); })}
); }; const noop = () => { }; ListMenu.propTypes = { options: PropTypes.array.isRequired, renderer: PropTypes.func.isRequired, onClick: PropTypes.func }; ListMenu.defaultProps = { onClick: noop }; export default ListMenu;