I need to apply a css class once to the LilCard component but not on the BigCard component. I do need to rendering them in the same map function so, I can't find a way to apply the "problem" class only to LilCard.
{results.map((item) => {
return (
<div className="problem"> <--- Here
{item.map((subitem, i) => {
if (i !== 0) {
return <LilCard article={subitem} />;
} else {
return <BigCard article={subitem} />;
}
})}
</div>
);
})}
The html is looking like this, i want BigCard to be wrapped with "col-lg-6 mb-5 mb-lg-0" class and LilCard to be wrapped in "col-lg-6 pl-lg-4" class.
<div class="row">
<div class="col-lg-6 mb-5 mb-lg-0">
<div class="entry2">
<a href="single.html"><img src="images/img_1.jpg" alt="Image" class="img-fluid rounded"></a>
<span class="post-category text-white bg-success mb-3">Nature</span>
<h2><a href="single.html">The 20 Biggest Fintech Companies In America 2019</a></h2>
<div class="post-meta align-items-center text-left clearfix">
<figure class="author-figure mb-0 mr-3 float-left"><img src="images/person_1.jpg"
alt="Image" class="img-fluid"></figure>
<span class="d-inline-block mt-1">By <a href="#">Carrol Atkinson</a></span>
<span> - February 10, 2019</span>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quo sunt tempora dolor laudantium
sed optio, explicabo ad deleniti impedit facilis fugit recusandae! Illo, aliquid, dicta
beatae quia porro id est.</p>
</div>
</div>
<div class="col-lg-6 pl-lg-4">
<div class="entry3 d-block d-sm-flex">
<figure class="figure order-2"><a href="single.html"><img src="images/img_2.jpg" alt="Image"
class="img-fluid rounded"></a></figure>
<div class="text mr-4 order-1">
<span class="post-category text-white bg-success mb-3">Nature</span>
<h2><a href="single.html">The 20 Biggest Fintech Companies In America 2019</a></h2>
<span class="post-meta mb-3 d-block">May 12, 2019</span>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quo sunt tempora dolor
laudantium sed optio.</p>
</div>
</div>
<div class="entry3 d-block d-sm-flex">
<figure class="figure order-2"><a href="single.html"><img src="images/img_3.jpg" alt="Image"
class="img-fluid rounded"></a></figure>
<div class="text mr-4 order-1">
<span class="post-category text-white bg-success mb-3">Nature</span>
<h2><a href="single.html">The 20 Biggest Fintech Companies In America 2019</a></h2>
<span class="post-meta mb-3 d-block">May 12, 2019</span>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quo sunt tempora dolor
laudantium sed optio.</p>
</div>
</div>
<div class="entry3 d-block d-sm-flex">
<figure class="figure order-2"><a href="single.html"><img src="images/img_4.jpg" alt="Image"
class="img-fluid rounded"></a></figure>
<div class="text mr-4 order-1">
<span class="post-category text-white bg-success mb-3">Nature</span>
<h2><a href="single.html">The 20 Biggest Fintech Companies In America 2019</a></h2>
<span class="post-meta mb-3 d-block">May 12, 2019</span>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quo sunt tempora dolor
laudantium sed optio.</p>
</div>
</div>
</div>
</div>
Thanks everyone.
question from:
https://stackoverflow.com/questions/65919847/conditional-rendering-react 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…