fe-bootcamp-2021 / bookstore

0 stars 0 forks source link

Use data in react way #37

Open vre2h opened 3 years ago

vre2h commented 3 years ago

https://github.com/fe-bootcamp-2021/bookstore/blob/050a5d581d031e4e6d7fba63c5d3bb8f89f06697/src/components/Slider/Slider.js#L8

Plz consider refactoring this:

const img = [
  <img alt="" key={slide1} src={slide1} width="100%" object-fit="cover"></img>,
  <img alt="" key={slide2} src={slide2} width="100%" object-fit="cover"></img>,
  <img alt="" key={slide3} src={slide3} width="100%" object-fit="cover"></img>,
];

to this

const images = [
 {src: slide1},
 {src: slide2},
 {src: slide3},
]

...

return images.map(({src}) => <img src={src} />)