import React, {Children, useState} from 'react'; import ErrorBoundary from "../ui/ErrorBoundary"; import ErrorBoundarySection from "../ui/ErrorBoundarySection"; type Props = { children: Array; className?: string; }; type Tab = { name: string | React.ReactElement; count: number; component: React.ComponentType; }; export default function DebugTabs({ children, className }: Props) { const [currentTabIndex, setCurrentTabIndex] = useState(0); const validChildren = children.filter((child) => child !== false) as Array; const tabs: Array = Children.map(validChildren, (child) => { return { name: child.props.name, component: child.props.component, count: child.props.count, checked: child.props.checked, onChange: child.props.onChange, }; }).filter((tab) => tab.count); const Tab = tabs[currentTabIndex].component; return (
}>
); } DebugTabs.Tab = (_props: Tab) => null;