🙆🏻♀️ [React] props 넘겨주기 🙆🏻♀️
Children 컴포넌트에 props 넘겨주기👶🏻
import React from "react";
import { Layout } from "antd";
const { Content } = Layout;
const CommonContainer = ({ children }) => {
return (
<Layout style={{ minHeight: "100vh" }}>
<Content>
{React.cloneElement(children, { props:"someProps" })}
</Content>
</Layout>
);
};
export default CommonContainer;
import React from "react";
import CommonContainer from "./CommonContainer";
import CotentComponent from "./Content";
const ContentLayout = () => {
return (
<CommonContainer>
<CotentComponent />
</CommonContainer>
);
};
export default ContentLayout;
import React from "react";
const ContentLayout = (props) => {
return (
{props}
);
};
export default ContentLayout;
똑똑!