【发布时间】:2019-04-15 15:26:14
【问题描述】:
目前我有以下
methodName = () => {
const {
collectionOfComponents
...
...
} = this.props;
return (
<Wrapper1>
{collectionOfComponents.map((oneComponent, index) => (
<Wrapper2
..props
>
{oneComponent.component}
</Wrapper2>
)}
</Wrapper1>
);
};
对于 collectionOfComponents,我将传递以下内容
collectionOfComponents={[
<ComponentOne prop1... prop2... />,
<ComponentOne prop1... prop2... />,
<ComponentTwo prop1... prop2... />
]}
有没有办法确定ComponentTwo 何时通过,以便我可以执行不同的渲染。我不知道该怎么做
编辑
对不起,应该说清楚,但我不想改变地图中的渲染方法我正在寻找一个单独的函数来首先检查componentTwo是否随时存在于数组中(也许) 使用第三类调用两种方法之一,这两种方法将是两种不同的返回方法。然后我会在 render 方法中调用函数
【问题讨论】:
标签: reactjs ecmascript-6 react-props