From e335da5391501347cd011cfd43761f1d47082b9c Mon Sep 17 00:00:00 2001 From: Paul Wackerow <54227730+wackerow@users.noreply.github.com> Date: Mon, 19 Dec 2022 15:17:17 -0800 Subject: [PATCH] move toggle handler to base component --- src/components/UI/docs/DocsLinks.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/UI/docs/DocsLinks.tsx b/src/components/UI/docs/DocsLinks.tsx index f743850bcb..014291746b 100644 --- a/src/components/UI/docs/DocsLinks.tsx +++ b/src/components/UI/docs/DocsLinks.tsx @@ -41,14 +41,16 @@ export const DocsLinks: FC = ({ navLinks, toggleMobileAccordion }) => { ) ); }, [asPath, navLinks]); + + const handleSectionToggle = (id: string): void => { + setOpenSections(prev => ({ ...prev, [id]: !prev[id] })); + }; + return ( {navLinks.map(({ id, to, items }, idx) => { const split = to?.split('/'); const isActive = slug && split && split[split.length - 1] === slug[slug.length - 1]; - const handleToggle = () => { - setOpenSections(prev => ({ ...prev, [id]: !prev[id] })); - }; return ( @@ -62,7 +64,7 @@ export const DocsLinks: FC = ({ navLinks, toggleMobileAccordion }) => { placeContent='flex-end' bg='button-bg' data-group - onClick={handleToggle} + onClick={() => handleSectionToggle(id)} >