import React from 'react'; import { Tabs, TabsProps } from 'antd'; const { TabPane } = Tabs; import history from 'lib/history'; const RouteTab = ({ routes, activeKey, onChangeHandler, ...rest }: RouteTabProps & TabsProps): JSX.Element => { const onChange = (activeRoute: string) => { onChangeHandler && onChangeHandler(); const selectedRoute = routes.find((e) => e.name === activeRoute); if (selectedRoute) { history.push(selectedRoute.route); } }; return ( {routes.map( ({ Component, name }): JSX.Element => ( ), )} ); }; interface RouteTabProps { routes: { name: string; route: string; Component: () => JSX.Element; }[]; activeKey: TabsProps['activeKey']; onChangeHandler?: VoidFunction; } export default RouteTab;