So I am trying to dynamically render a component with its properties when I click on a button on another page with dynamic routes. My route path is:
<Route path="/prod/:id/:descr/:price/:image"><MakePurchase /></Route>
then I set up a link also as follows:
<Link to={"/prod/"+product.id+"/"+product.descr+"/"+product.price+""+product.image}>
In the component I want to render looks like this:
return(
<>
...
<img src={props.match.params.image} alt=""/>
...
<h2>{props.match.params.descr}</h2>
<h3>Price: <span >₦</span>{props.match.params.price}</h3>
...
</>
)
}
the values for price and descr are returned perfectly but for image, there is no image displayed. I did a console.error(props) which returns values like this
isExact: false
params:
descr: "PS5 Dual Sense Wireless Controller"
id: "300"
image: "static"
price: "25000"
Please, how do I get the correct path for my image and display the image on the page?