Создали props для компонента Products, отмаппили полученные товары на странице
This commit is contained in:
+8
-15
@@ -1,5 +1,4 @@
|
|||||||
import styles from './App.module.scss'
|
import styles from './App.module.scss'
|
||||||
import SneakersImage from './assets/images/sneakers-image.jpg'
|
|
||||||
import { FaRegUser } from 'react-icons/fa'
|
import { FaRegUser } from 'react-icons/fa'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
@@ -23,7 +22,7 @@ function Header() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function Product() {
|
function Product({ name, description, price, imageUrl }) {
|
||||||
const [isLiked, setIsLiked] = React.useState(false)
|
const [isLiked, setIsLiked] = React.useState(false)
|
||||||
|
|
||||||
const toggleLike = () => {
|
const toggleLike = () => {
|
||||||
@@ -36,10 +35,10 @@ function Product() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.product}>
|
<div className={styles.product}>
|
||||||
<img src={SneakersImage} alt='' />
|
<img src={imageUrl} alt='' />
|
||||||
<div className={styles.content}>
|
<div className={styles.content}>
|
||||||
<div className={styles.title}>
|
<div className={styles.title}>
|
||||||
<h4>Sneakers Red & White 2025</h4>
|
<h4>{name}</h4>
|
||||||
<div className={styles.actions}>
|
<div className={styles.actions}>
|
||||||
<button
|
<button
|
||||||
className={styles.likeButton}
|
className={styles.likeButton}
|
||||||
@@ -60,8 +59,8 @@ function Product() {
|
|||||||
<button onClick={handleAddClick}>+</button>
|
<button onClick={handleAddClick}>+</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p className={styles.description}>NIKE</p>
|
<p className={styles.description}>{description}</p>
|
||||||
<p className={styles.price}>$38.00</p>
|
<p className={styles.price}>${price}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@@ -80,8 +79,6 @@ function App() {
|
|||||||
getProducts()
|
getProducts()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
console.log(products)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
@@ -89,15 +86,11 @@ function App() {
|
|||||||
</div>
|
</div>
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
<ul className={styles.list}>
|
<ul className={styles.list}>
|
||||||
|
{products.map(product => (
|
||||||
<li>
|
<li>
|
||||||
<Product />
|
<Product {...product} />
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<Product />
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<Product />
|
|
||||||
</li>
|
</li>
|
||||||
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
Reference in New Issue
Block a user