import { useState, useCallback, memo } from 'react'; import variables from 'config/variables'; import Tab from './Tab'; import { useTab } from './TabContext'; const Sidebar = memo(({ sections, currentTab, setCurrentTab }) => { const { subTab, setSubTab, setSubSection } = useTab(); const handleClick = useCallback( (label) => () => { setCurrentTab(variables.getMessage(label)); setSubTab(variables.getMessage(label)); setSubSection(''); }, [setCurrentTab, setSubTab, setSubSection], ); return (
{sections.map((section, index) => ( ))}
); }); const Content = memo(({ sections, currentTab }) => ( <> {sections.map( ({ label, name, component: Component }) => variables.getMessage(label) === currentTab && (
), )} )); const Tabs = ({ sections }) => { const [currentTab, setCurrentTab] = useState(variables.getMessage(sections[0].label)); return (
); }; export { Tabs };