I understand the concept of key in a loop on basic level.
But my html is such that I am getting confused.
Here's the loop I need help in placing the key at. key=product.id
ALso, if we have selected one of the div, how do we change it from bg-success to bg-primary?
{products.map(product => (
<div className="col-md-6 col-sm-12 col-xs-12">
<div className="card rounded bg-success p-5 my-3 mr-3 text-center">
<h4>{product.title}</h4>
<h1 className="price">${product.price}</h1>
<ul className="no-disk">
<li key={product.id}>{product.month_count}</li>
<li>{product.time} Package</li>
</ul>
<img className="img-responsive " src="images/store.png" />
</div>
</div>
))}