// Layout.jsx
// import 생략
const Layout = ({ title, main, urlToPost }) => {
return (
<div className={comu.wrapper}>
<div className={header.header}>{title}</div>
<div className={comu.mainContainer>{main}</div>
<Link href={urlToPost} passHref>
<a className={styles.addBtn}>+</a>
</Link>
</div>
);
};
export default Layout;
// page.jsx
// import 생략
const Index = () => {
return (
<MainPage
title={"Community"}
main={<Content></Content>}
urlToPost={"/"}
></MainPage>
);
};
const Content = () => {
return <div>
<p>컴포넌트로</p>
<p>만들 수 있어</p>
</div>;
};
export default Index;
참고: https://www.sitepoint.com/creating-reusable-react-components/