import React, { useState } from 'react'; import classnames from 'classnames'; import PropTypes from 'prop-types'; import { Tabs, Tab, Paper } from '@material-ui/core'; import TabPanel from './TabPanel'; import { useStyles } from './styles'; import { useHistory } from 'react-router-dom'; const a11yProps = index => ({ id: `tab-${index}`, 'aria-controls': `tabpanel-${index}`, }); const TabNav = ({ tabData, className, navClass, startingTab = 0 }) => { const styles = useStyles(); const [activeTab, setActiveTab] = useState(startingTab); const history = useHistory(); const renderTabs = () => tabData.map((tab, index) => ( history.push(tab.path)} /> )); const renderTabPanels = () => tabData.map((tab, index) => ( {tab.component} )); return ( <> { setActiveTab(tabId); }} indicatorColor="primary" textColor="primary" centered > {renderTabs()}
{renderTabPanels()}
); }; TabNav.propTypes = { tabData: PropTypes.array.isRequired, className: PropTypes.string, startingTab: PropTypes.number, }; export default TabNav;