【发布时间】:2021-12-04 20:30:01
【问题描述】:
我正在尝试通过以下方式在另一个组件中呈现组件。即使我尝试在组件中呈现 div 元素,它也不会显示。
const Sandbox = () => {
return (
<div>
<RenderHtml
Title="This is the title"
Description="This is the description">
<Example message="Hello World" />
<h1>Render somthing here</h1>
</RenderHtml>
</div>
);
};
export default Sandbox;
下面是RenderHtml组件的代码
const MyCard = styled(Card)();
const RenderHtml = (props: any) => {
return (
<MyCard>
<div
style={{
display: "flex",
justifyContent: "space-between",
flexDirection: "column",
}}
>
<Typography variant="h1" sx={{ textAlign: "center" }}>
{props.Title}
</Typography>
<Typography variant="subtitle1" sx={{ textAlign: "center" }}>
{props.Description}
</Typography>
</div>
</MyCard>
);
};
export default RenderHtml;
我浏览了不同的示例和教程,无法理解如何渲染。如果有人可以帮助我解决这个问题。
【问题讨论】:
-
是
<RenderHtml>里面的东西没有渲染吗?如果是这样,你能告诉我们RenderHtml的代码吗? -
@NicholasTower 我编辑了我的问题,包括
标签: reactjs typescript components render