When I click on the Link parent it fires the click on the button as well, I want both events to be separated.
<Link className="product-item__link" to={`/products/${product.category}/${product.id}`} >
<div className='product-item'>
{/*I have here other elements*/}
<button className="product-item__btn" onClick={() => addToCart(product)}>Add to cart</button>
</div>
</Link>
2
Answers
Add stop propagation in the function call of button click
change function definition