【发布时间】:2021-03-28 17:17:46
【问题描述】:
目标: 在 switch 语句中返回两个组件。具体来说,如何渲染我的 LinkButtonTypes 和 LinkList 组件?
这是我的 switch 语句:
const switchComponent = ({ selectedSidebar }) => {
let component;
switch (selectedSidebar) {
// main dashboard components
case "dashboard":
component = <LinkButtonTypes setLinkType={setLinkType} /> && (
<LinkList/>
);
break;
// render editor components
case "skins":
component = <SkinsEditor />;
break;
default:
console.log("Unknwon switch component");
}
return component;
};
这里是我渲染组件的地方:
<div className="dash__middle">
{switchComponent({ selectedSidebar })}
</div>
目前,switch 语句只呈现我的LinkButtonTypes 组件。
如何渲染我的LinkButtonTypes 和LinkList 组件?
【问题讨论】:
标签: reactjs