//layouts.tsx
interface LayoutProps {
children: React.ReactNode; (1)
}
export const SubMenuLayout: React.FC<LayoutProps> =
(props: LayoutProps) => { (2)
return (
<>
<SubMenuContainer>
<div className='part'>{props.children}</div> (3)
</SubMenuContainer>
</>
);
};
//ContentsPage.tsx
const ContentsPage = () => {
return (
<>
{subMenuList.map((el, idx) => ( (4)
<SubMenuLayout key={idx}>{el}</SubMenuLayout>
))} (5)
<AdvSection />
<ContentSection></ContentSection>
</>
);
};
export default ContentsPage;
(4), (5) submenu에 들어가는 메뉴항목의 컴포넌트 array를 상수로 만들어 map을 활용해 나열했다.
완성