import React, { useState } from 'react'; import { Wrapper, BtnGroup, Btn } from './styled'; type OptionProps = { key: string; content: React.ReactNode; child: React.ReactNode; }; type Props = { options: OptionProps[]; }; const Tabs: React.FunctionComponent = ({ options, }) => { const [selectedIndex, setSelect] = useState(0); const handleClick = (index: number) => { setSelect(index); }; return ( { options.map((ele, index) => ( { handleClick(index); }} > {ele.content} )) } {options[selectedIndex] ? options[selectedIndex].child : null} ); }; export default Tabs;