import { Tabs } from "@chakra-ui/react" import { Children } from "react" interface CodeGroupProps { children: React.ReactElement } export const CodeGroup: React.FC = (props) => { const { children } = props const titles: React.ReactNode[] = [] const contents: React.ReactNode[] = [] let firstTitle = "" Children.forEach(children, (child: React.ReactElement, index: number) => { const title = child.props["data-title"] if (index === 0) firstTitle = title titles.push( {title} , ) contents.push( {child.props.children} , ) }) return ( {titles} {contents} ) }