'Click an img on react to redirect to another component
I am trying to click on an image of the product, and redirect to a product show page to show the specific product. I am using ruby on rails as backend.
render(){
const {loading, error, products} = this.state
// console.log("CHECK Render PRODUCT", this.state)
if (error){
return <p>Error loading</p>
}
const productsList = products.map(p =>
<li key={p.id}>
name: {p.name} <br />
description: {p.description} <br />
price: {p.price} <br />
stock: {p.stock} <br/>
<Link to={`./products/${p.id}`}>
<img className="product_image" src={`http://localhost:3000/assets/${p.image}`} alt={p.name} />
</Link>
</li>
)
this is in my Products.js file. It seems like the link to doesn't work? How do I fix this?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
