Please tell me how I can passing props to component (Card) in dynamic routing. I get array from JSON and put it to Redux. Example JSON:
{
"product": [
{
"id": 1,
"image": "/assets/images/products/27672/1.jpg",
"name": "Product 1",
"price": "0.20",
"category": 2
},
{
"id": 2,
"image": "/assets/images/products/27672/2.jpg",
"name": "Product 2",
"price": "0.1",
"category": 3
}
]
}
App component:
<div className="App">
<Header />
<Routes>
<Route path='/' element={<Home />} />
<Route path='/product/:id' element={<Card />} />
</Routes>
<Footer />
</div>
Link on product in Home component. Clicking on the link should take to product page. Id product from JSON.
<div className="catalog_block">
<Link to={'product/' + id}>
<img src={image} />
</Link>
</div>