Skip to content

Instantly share code, notes, and snippets.

@Risyandi
Created December 10, 2020 07:24
Show Gist options
  • Save Risyandi/ba7c96990f2401e0a4baedc278d1b4dd to your computer and use it in GitHub Desktop.
Save Risyandi/ba7c96990f2401e0a4baedc278d1b4dd to your computer and use it in GitHub Desktop.
example swiper in react
import {SwiperSlide, Swiper} from 'swiper/react';
import SwiperCore, {Pagination, Autoplay} from 'swiper';
SwiperCore.use([Pagination, Autoplay]);
const Home = (props) => {
const [banner, setBanner] = useState([])
// get data from api
setbanner(API_DATA);
return (
<Swiper
pagination={{clickable: true }}>
{
banner.map((row, idx) => {
return (
<SwiperSlide key={idx}>
<img src={row.urlImage} alt="images"/>
</SwiperSlide>
)
})
}
</Swiper>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment