import React from 'react'; import { NavLink, RouteComponentProps } from 'react-router-dom'; import './SubTabs.scss'; export interface Tab { name: string | React.ReactElement; path: string; disabled?: boolean; redirect?: string; } interface Props { tabs: Tab[]; match: RouteComponentProps<{}>['match']; } export default class SubTabs extends React.PureComponent { public render() { const { tabs, match } = this.props; const currentPath = match.url; return (
{tabs.map((t, i) => ( // Same as normal Link, but knows when it's active, and applies activeClassName {t.name} ))}
); } }