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